Add and apply rubocop rules for empty lines

We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
This commit is contained in:
Javi Martín
2019-10-24 15:48:37 +02:00
parent b6750e8f17
commit db97f9d08c
585 changed files with 24 additions and 1645 deletions

View File

@@ -1,5 +1,4 @@
module ActiveModel::Dates
def parse_date(field, attrs)
year, month, day = attrs["#{field}(1i)"],
attrs["#{field}(2i)"],
@@ -12,5 +11,4 @@ module ActiveModel::Dates
def remove_date(field, attrs)
attrs.except("#{field}(1i)", "#{field}(2i)", "#{field}(3i)")
end
end

View File

@@ -1,9 +1,7 @@
module ActsAsParanoidAliases
def self.included(base)
base.extend(ClassMethods)
class_eval do
def hide
return false if hidden?
update_attribute(:hidden_at, Time.current)

View File

@@ -1,6 +1,5 @@
include DocumentParser
class CensusApi
def call(document_type, document_number)
response = nil
get_document_number_variants(document_type, document_number).each do |variant|
@@ -122,5 +121,4 @@ class CensusApi
def stubbed_invalid_response
{ get_habita_datos_response: { get_habita_datos_return: { datos_habitante: {}, datos_vivienda: {}}}}
end
end

View File

@@ -1,5 +1,4 @@
class CensusCaller
def call(document_type, document_number, date_of_birth, postal_code)
if Setting["feature.remote_census"].present?
response = RemoteCensusApi.new.call(document_type, document_number, date_of_birth, postal_code)

View File

@@ -1,5 +1,4 @@
class CommentTree
ROOT_COMMENTS_PER_PAGE = 10
attr_reader :commentable, :page, :order

View File

@@ -1,5 +1,4 @@
module DocumentParser
def get_document_number_variants(document_type, document_number)
# Delete all non-alphanumerics
document_number = document_number.to_s.gsub(/[^0-9A-Za-z]/i, "")
@@ -61,5 +60,4 @@ module DocumentParser
def dni?(document_type)
document_type.to_s == "1"
end
end

View File

@@ -1,5 +1,4 @@
class EmailDigest
attr_accessor :user
def initialize(user)
@@ -29,5 +28,4 @@ class EmailDigest
def valid_email?
user.email.present? && user.email.match(/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i)
end
end

View File

@@ -22,6 +22,7 @@ class EvaluationCommentEmail
end
private
def related_users
return [] if comment.commentable.nil?
comment.commentable

View File

@@ -29,9 +29,7 @@ module GraphQL
end
def self.create_type(model, fields, created_types)
created_types[model] = GraphQL::ObjectType.define do
name model.graphql_type_name
description model.graphql_type_description
@@ -54,7 +52,6 @@ module GraphQL
end
end
end
end
end

View File

@@ -2,7 +2,6 @@ require "graphql"
module GraphQL
class QueryTypeCreator
def self.create(api_types)
GraphQL::ObjectType.define do
name "QueryType"
@@ -22,10 +21,8 @@ module GraphQL
description model.graphql_pluralized_field_description
resolve ->(object, arguments, context) { model.public_for_api }
end
end
end
end
end
end

View File

@@ -1,6 +1,5 @@
include DocumentParser
class LocalCensus
def call(document_type, document_number)
record = nil
get_document_number_variants(document_type, document_number).each do |variant|
@@ -62,5 +61,4 @@ class LocalCensus
def get_record(document_type, document_number)
LocalCensusRecord.find_by(document_type: document_type, document_number: document_number)
end
end

View File

@@ -1,5 +1,4 @@
class ManagerAuthenticator
def initialize(data = {})
@manager = { login: data[:login], user_key: data[:clave_usuario], date: data[:fecha_conexion] }.with_indifferent_access
end

View File

@@ -9,5 +9,4 @@ class MergedCommentTree < CommentTree
def base_comments
Comment.where(commentable: commentables.flatten)
end
end

View File

@@ -1,6 +1,5 @@
include DocumentParser
class RemoteCensusApi
def call(document_type, document_number, date_of_birth, postal_code)
response = nil
get_document_number_variants(document_type, document_number).each do |variant|
@@ -154,5 +153,4 @@ class RemoteCensusApi
def stubbed_invalid_response
{ get_habita_datos_response: { get_habita_datos_return: { datos_habitante: {}, datos_vivienda: {}}}}
end
end

View File

@@ -4,7 +4,6 @@ require "cgi"
require "json"
class RemoteTranslations::Microsoft::AvailableLocales
def self.available_locales
daily_cache("locales") do
remote_available_locales.map { |locale| locale.first }
@@ -51,5 +50,4 @@ class RemoteTranslations::Microsoft::AvailableLocales
def self.daily_cache(key, &block)
Rails.cache.fetch("remote_available_locales/#{Time.current.strftime("%Y-%m-%d")}/#{key}", &block)
end
end

View File

@@ -77,5 +77,4 @@ class RemoteTranslations::Microsoft::Client
def notranslate?(text)
text.downcase == PREVENTING_TRANSLATION_KEY
end
end

View File

@@ -1,5 +1,4 @@
module RemoteTranslations::Microsoft::SentencesParser
def detect_split_position(text)
limit = RemoteTranslations::Microsoft::Client::CHARACTERS_LIMIT_PER_REQUEST
minimum_valid_index = text.size - limit
@@ -21,5 +20,4 @@ module RemoteTranslations::Microsoft::SentencesParser
def characters_count(texts)
texts.map(&:size).reduce(:+)
end
end

View File

@@ -1,5 +1,4 @@
module ScoreCalculator
def self.hot_score(resource)
return 0 unless resource.created_at
@@ -31,5 +30,4 @@ module ScoreCalculator
def self.resource_age(resource)
((Time.current - resource.created_at) / 1.day).ceil
end
end

View File

@@ -53,5 +53,4 @@ class SMSApi
}
}
end
end

View File

@@ -16,5 +16,4 @@ class TagSanitizer
def self.tag_max_length
160
end
end

View File

@@ -1,6 +1,5 @@
namespace :budgets do
namespace :email do
desc "Sends emails to authors of selected investments"
task selected: :environment do
Budget.last.email_selected
@@ -10,7 +9,6 @@ namespace :budgets do
task unselected: :environment do
Budget.last.email_unselected
end
end
desc "Update investments original_heading_id with current heading_id"
@@ -23,5 +21,4 @@ namespace :budgets do
print "."
end
end
end

View File

@@ -1,5 +1,4 @@
namespace :dashboards do
desc "Send to user notifications from new actions availability on dashboard"
task send_notifications: :environment do
Proposal.not_archived.each do |proposal|

View File

@@ -1,5 +1,4 @@
namespace :votes do
desc "Resets cached_votes_up counter to its latest value"
task reset_vote_counter: :environment do
models = [Proposal, Budget::Investment]
@@ -10,7 +9,6 @@ namespace :votes do
print "."
end
end
end
desc "Resets hot_score to its new value"

View File

@@ -10,5 +10,4 @@ class WYSIWYGSanitizer
def sanitize(html)
ActionController::Base.helpers.sanitize(html, tags: allowed_tags, attributes: allowed_attributes)
end
end