Rubocop fixes and rubocop todo update for those that can't be done right now

This commit is contained in:
Bertocq
2017-10-17 22:06:07 +02:00
parent ce0a7f6fad
commit 7b40c84166
5 changed files with 65 additions and 79 deletions

View File

@@ -1,12 +1,12 @@
# This configuration was generated by # This configuration was generated by
# `rubocop --auto-gen-config` # `rubocop --auto-gen-config`
# on 2017-07-07 21:23:30 +0200 using RuboCop version 0.49.1. # on 2017-10-17 22:05:23 +0200 using RuboCop version 0.49.1.
# The point is for the user to remove these configuration records # The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base. # one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new # Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again. # versions of RuboCop, may require this file to be generated again.
# Offense count: 45 # Offense count: 40
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedHashRocketStyle, SupportedHashRocketStyles, EnforcedColonStyle, SupportedColonStyles, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles. # Configuration parameters: EnforcedHashRocketStyle, SupportedHashRocketStyles, EnforcedColonStyle, SupportedColonStyles, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles.
# SupportedHashRocketStyles: key, separator, table # SupportedHashRocketStyles: key, separator, table
@@ -14,11 +14,10 @@
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
Layout/AlignHash: Layout/AlignHash:
Exclude: Exclude:
- 'app/controllers/officing/results_controller.rb'
- 'spec/controllers/legislation/annotations_controller_spec.rb' - 'spec/controllers/legislation/annotations_controller_spec.rb'
- 'spec/features/admin/banners_spec.rb' - 'spec/features/admin/banners_spec.rb'
# Offense count: 50 # Offense count: 52
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: with_first_parameter, with_fixed_indentation # SupportedStyles: with_first_parameter, with_fixed_indentation
@@ -33,7 +32,7 @@ Layout/ClosingParenthesisIndentation:
- 'spec/models/legislation/annotation_spec.rb' - 'spec/models/legislation/annotation_spec.rb'
- 'spec/rails_helper.rb' - 'spec/rails_helper.rb'
# Offense count: 51 # Offense count: 37
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: leading, trailing # SupportedStyles: leading, trailing
@@ -68,11 +67,10 @@ Layout/EmptyLines:
Exclude: Exclude:
- 'app/controllers/admin/budget_investment_milestones_controller.rb' - 'app/controllers/admin/budget_investment_milestones_controller.rb'
# Offense count: 2 # Offense count: 1
# Cop supports --auto-correct. # Cop supports --auto-correct.
Layout/EmptyLinesAroundMethodBody: Layout/EmptyLinesAroundMethodBody:
Exclude: Exclude:
- 'app/models/abilities/administrator.rb'
- 'lib/graph_ql/api_types_creator.rb' - 'lib/graph_ql/api_types_creator.rb'
# Offense count: 2 # Offense count: 2
@@ -126,13 +124,13 @@ Layout/IndentationConsistency:
- 'spec/models/legislation/draft_version_spec.rb' - 'spec/models/legislation/draft_version_spec.rb'
- 'spec/models/proposal_spec.rb' - 'spec/models/proposal_spec.rb'
# Offense count: 23 # Offense count: 48
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: Width, IgnoredPatterns. # Configuration parameters: Width, IgnoredPatterns.
Layout/IndentationWidth: Layout/IndentationWidth:
Enabled: false Enabled: false
# Offense count: 7 # Offense count: 6
# Cop supports --auto-correct. # Cop supports --auto-correct.
Layout/LeadingCommentSpace: Layout/LeadingCommentSpace:
Exclude: Exclude:
@@ -140,7 +138,6 @@ Layout/LeadingCommentSpace:
- 'app/controllers/budgets/ballot/lines_controller.rb' - 'app/controllers/budgets/ballot/lines_controller.rb'
- 'spec/features/budgets/ballots_spec.rb' - 'spec/features/budgets/ballots_spec.rb'
- 'spec/features/comments/poll_questions_spec.rb' - 'spec/features/comments/poll_questions_spec.rb'
- 'spec/features/officing/voters_spec.rb'
- 'spec/support/common_actions.rb' - 'spec/support/common_actions.rb'
# Offense count: 3 # Offense count: 3
@@ -181,7 +178,7 @@ Layout/MultilineMethodCallBraceLayout:
- 'spec/models/legislation/annotation_spec.rb' - 'spec/models/legislation/annotation_spec.rb'
- 'spec/rails_helper.rb' - 'spec/rails_helper.rb'
# Offense count: 71 # Offense count: 59
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: aligned, indented, indented_relative_to_receiver # SupportedStyles: aligned, indented, indented_relative_to_receiver
@@ -201,7 +198,7 @@ Layout/MultilineMethodCallIndentation:
- 'spec/models/proposal_spec.rb' - 'spec/models/proposal_spec.rb'
- 'spec/models/user_spec.rb' - 'spec/models/user_spec.rb'
# Offense count: 8 # Offense count: 7
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: aligned, indented # SupportedStyles: aligned, indented
@@ -264,22 +261,7 @@ Lint/LiteralInCondition:
Exclude: Exclude:
- 'app/models/budget/investment.rb' - 'app/models/budget/investment.rb'
# Offense count: 51 # Offense count: 3
Lint/ParenthesesAsGroupedExpression:
Exclude:
- 'spec/factories.rb'
- 'spec/features/admin/organizations_spec.rb'
- 'spec/features/budgets/investments_spec.rb'
- 'spec/features/campaigns_spec.rb'
- 'spec/features/debates_spec.rb'
- 'spec/features/management/managed_users_spec.rb'
- 'spec/features/management/proposals_spec.rb'
- 'spec/features/management/spending_proposals_spec.rb'
- 'spec/features/management/users_spec.rb'
- 'spec/features/proposals_spec.rb'
- 'spec/models/debate_spec.rb'
# Offense count: 13
# Cop supports --auto-correct. # Cop supports --auto-correct.
Lint/StringConversionInInterpolation: Lint/StringConversionInInterpolation:
Exclude: Exclude:
@@ -308,7 +290,7 @@ Lint/UnusedMethodArgument:
- 'app/mailers/mailer.rb' - 'app/mailers/mailer.rb'
- 'app/models/abilities/everyone.rb' - 'app/models/abilities/everyone.rb'
# Offense count: 278 # Offense count: 325
Lint/UselessAssignment: Lint/UselessAssignment:
Enabled: false Enabled: false
@@ -317,35 +299,46 @@ Lint/Void:
Exclude: Exclude:
- 'app/controllers/polls_controller.rb' - 'app/controllers/polls_controller.rb'
# Offense count: 74 # Offense count: 86
Metrics/AbcSize: Metrics/AbcSize:
Max: 54 Max: 64
# Offense count: 454 # Offense count: 487
# Configuration parameters: CountComments, ExcludedMethods. # Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength: Metrics/BlockLength:
Max: 1071 Max: 1227
# Offense count: 8
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 256
# Offense count: 10 # Offense count: 10
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 262
# Offense count: 13
Metrics/CyclomaticComplexity: Metrics/CyclomaticComplexity:
Max: 10 Max: 10
# Offense count: 53 # Offense count: 25
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 248
# Offense count: 67
# Configuration parameters: CountComments. # Configuration parameters: CountComments.
Metrics/MethodLength: Metrics/MethodLength:
Max: 49 Max: 56
# Offense count: 1 # Offense count: 1
# Configuration parameters: CountComments. # Configuration parameters: CountComments.
Metrics/ModuleLength: Metrics/ModuleLength:
Max: 214 Max: 242
# Offense count: 7 # Offense count: 3
# Configuration parameters: CountKeywordArgs.
Metrics/ParameterLists:
Max: 7
# Offense count: 8
Metrics/PerceivedComplexity: Metrics/PerceivedComplexity:
Max: 11 Max: 11
@@ -399,20 +392,20 @@ Rails/HttpPositionalArguments:
- 'spec/controllers/pages_controller_spec.rb' - 'spec/controllers/pages_controller_spec.rb'
- 'spec/controllers/users/registrations_controller_spec.rb' - 'spec/controllers/users/registrations_controller_spec.rb'
# Offense count: 20 # Offense count: 18
Rails/OutputSafety: Rails/OutputSafety:
Exclude: Exclude:
- 'app/controllers/admin/legislation/draft_versions_controller.rb' - 'app/controllers/admin/legislation/draft_versions_controller.rb'
- 'app/controllers/admin/legislation/processes_controller.rb' - 'app/controllers/admin/legislation/processes_controller.rb'
- 'app/controllers/admin/legislation/questions_controller.rb' - 'app/controllers/admin/legislation/questions_controller.rb'
- 'app/controllers/budgets/investments_controller.rb' - 'app/controllers/budgets/investments_controller.rb'
- 'app/controllers/direct_uploads_controller.rb'
- 'app/controllers/spending_proposals_controller.rb' - 'app/controllers/spending_proposals_controller.rb'
- 'app/helpers/application_helper.rb' - 'app/helpers/application_helper.rb'
- 'app/helpers/text_with_links_helper.rb' - 'app/helpers/text_with_links_helper.rb'
- 'app/helpers/users_helper.rb'
- 'app/helpers/valuation_helper.rb' - 'app/helpers/valuation_helper.rb'
# Offense count: 70 # Offense count: 71
# Configuration parameters: Blacklist. # Configuration parameters: Blacklist.
# Blacklist: decrement!, decrement_counter, increment!, increment_counter, toggle!, touch, update_all, update_attribute, update_column, update_columns, update_counters # Blacklist: decrement!, decrement_counter, increment!, increment_counter, toggle!, touch, update_all, update_attribute, update_column, update_columns, update_counters
Rails/SkipsModelValidations: Rails/SkipsModelValidations:
@@ -428,7 +421,7 @@ Style/AccessorMethodName:
- 'app/controllers/proposals_controller.rb' - 'app/controllers/proposals_controller.rb'
- 'lib/merged_comment_tree.rb' - 'lib/merged_comment_tree.rb'
# Offense count: 1 # Offense count: 8
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: braces, no_braces, context_dependent # SupportedStyles: braces, no_braces, context_dependent
@@ -438,7 +431,7 @@ Style/BracesAroundHashParameters:
- 'spec/features/budgets/investments_spec.rb' - 'spec/features/budgets/investments_spec.rb'
- 'spec/features/proposals_spec.rb' - 'spec/features/proposals_spec.rb'
# Offense count: 119 # Offense count: 123
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: nested, compact # SupportedStyles: nested, compact
Style/ClassAndModuleChildren: Style/ClassAndModuleChildren:
@@ -451,14 +444,13 @@ Style/ClassVars:
- 'app/models/organization.rb' - 'app/models/organization.rb'
- 'app/models/user.rb' - 'app/models/user.rb'
# Offense count: 12 # Offense count: 8
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly, IncludeTernaryExpressions. # Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly, IncludeTernaryExpressions.
# SupportedStyles: assign_to_condition, assign_inside_condition # SupportedStyles: assign_to_condition, assign_inside_condition
Style/ConditionalAssignment: Style/ConditionalAssignment:
Exclude: Exclude:
- 'app/controllers/admin/poll/booth_assignments_controller.rb' - 'app/controllers/admin/poll/booth_assignments_controller.rb'
- 'app/controllers/admin/poll/officer_assignments_controller.rb'
- 'app/controllers/admin/poll/questions_controller.rb' - 'app/controllers/admin/poll/questions_controller.rb'
- 'app/controllers/comments_controller.rb' - 'app/controllers/comments_controller.rb'
- 'app/controllers/management/spending_proposals_controller.rb' - 'app/controllers/management/spending_proposals_controller.rb'
@@ -484,7 +476,7 @@ Style/FileName:
Style/GuardClause: Style/GuardClause:
Enabled: false Enabled: false
# Offense count: 12 # Offense count: 11
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: MaxLineLength. # Configuration parameters: MaxLineLength.
Style/IfUnlessModifier: Style/IfUnlessModifier:
@@ -495,19 +487,19 @@ Style/IfUnlessModifier:
- 'app/controllers/legislation/annotations_controller.rb' - 'app/controllers/legislation/annotations_controller.rb'
- 'app/controllers/valuation/budget_investments_controller.rb' - 'app/controllers/valuation/budget_investments_controller.rb'
- 'app/controllers/verification/letter_controller.rb' - 'app/controllers/verification/letter_controller.rb'
- 'app/controllers/welcome_controller.rb'
- 'app/helpers/embed_videos_helper.rb' - 'app/helpers/embed_videos_helper.rb'
- 'app/mailers/mailer.rb' - 'app/mailers/mailer.rb'
- 'app/models/proposal.rb' - 'app/models/proposal.rb'
- 'app/models/spending_proposal.rb' - 'app/models/spending_proposal.rb'
# Offense count: 4 # Offense count: 5
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: line_count_dependent, lambda, literal # SupportedStyles: line_count_dependent, lambda, literal
Style/Lambda: Style/Lambda:
Exclude: Exclude:
- 'app/models/comment.rb' - 'app/models/comment.rb'
- 'app/models/concerns/followable.rb'
- 'app/models/direct_message.rb' - 'app/models/direct_message.rb'
- 'app/models/vote.rb' - 'app/models/vote.rb'
- 'lib/graph_ql/api_types_creator.rb' - 'lib/graph_ql/api_types_creator.rb'
@@ -523,7 +515,7 @@ Style/MultilineIfThen:
Exclude: Exclude:
- 'app/controllers/management/users_controller.rb' - 'app/controllers/management/users_controller.rb'
# Offense count: 15 # Offense count: 13
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/MutableConstant: Style/MutableConstant:
Exclude: Exclude:
@@ -546,7 +538,7 @@ Style/MutableConstant:
Style/NumericLiterals: Style/NumericLiterals:
MinDigits: 9 MinDigits: 9
# Offense count: 19 # Offense count: 20
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles. # Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles.
# SupportedStyles: predicate, comparison # SupportedStyles: predicate, comparison
@@ -574,7 +566,7 @@ Style/ParallelAssignment:
- 'lib/active_model/dates.rb' - 'lib/active_model/dates.rb'
- 'spec/support/common_actions.rb' - 'spec/support/common_actions.rb'
# Offense count: 11 # Offense count: 10
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist. # Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
# NamePrefix: is_, has_, have_ # NamePrefix: is_, has_, have_
# NamePrefixBlacklist: is_, has_, have_ # NamePrefixBlacklist: is_, has_, have_
@@ -588,7 +580,6 @@ Style/PredicateName:
- 'app/helpers/debates_helper.rb' - 'app/helpers/debates_helper.rb'
- 'app/models/budget/ballot.rb' - 'app/models/budget/ballot.rb'
- 'app/models/user.rb' - 'app/models/user.rb'
- 'lib/census_api.rb'
# Offense count: 4 # Offense count: 4
# Cop supports --auto-correct. # Cop supports --auto-correct.
@@ -608,13 +599,14 @@ Style/RedundantBegin:
- 'app/controllers/graphql_controller.rb' - 'app/controllers/graphql_controller.rb'
- 'app/models/legislation/annotation.rb' - 'app/models/legislation/annotation.rb'
# Offense count: 3 # Offense count: 5
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes. # Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
# SupportedStyles: slashes, percent_r, mixed # SupportedStyles: slashes, percent_r, mixed
Style/RegexpLiteral: Style/RegexpLiteral:
Exclude: Exclude:
- 'app/helpers/embed_videos_helper.rb' - 'app/helpers/embed_videos_helper.rb'
- 'app/models/poll/question/answer/video.rb'
- 'spec/customization_engine_spec.rb' - 'spec/customization_engine_spec.rb'
# Offense count: 6 # Offense count: 6
@@ -633,22 +625,16 @@ Style/SafeNavigation:
Exclude: Exclude:
- 'app/models/signature.rb' - 'app/models/signature.rb'
# Offense count: 9 # Offense count: 93
# Configuration parameters: SupportedStyles.
# SupportedStyles: snake_case, camelCase
Style/VariableName:
EnforcedStyle: snake_case
# Offense count: 107
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: snake_case, normalcase, non_integer # SupportedStyles: snake_case, normalcase, non_integer
Style/VariableNumber: Style/VariableNumber:
Enabled: false Enabled: false
# Offense count: 31 # Offense count: 34
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: SupportedStyles, WordRegex. # Configuration parameters: SupportedStyles, WordRegex.
# SupportedStyles: percent, brackets # SupportedStyles: percent, brackets
Style/WordArray: Style/WordArray:
EnforcedStyle: percent EnforcedStyle: percent
MinSize: 9 MinSize: 8

View File

@@ -9,10 +9,10 @@ module ImageablesHelper
end end
def imageable_max_file_size def imageable_max_file_size
bytesToMeg(Image::MAX_IMAGE_SIZE) bytes_to_megabytes(Image::MAX_IMAGE_SIZE)
end end
def bytesToMeg(bytes) def bytes_to_megabytes(bytes)
bytes / Numeric::MEGABYTE bytes / Numeric::MEGABYTE
end end
@@ -37,4 +37,4 @@ module ImageablesHelper
max_file_size: imageable_max_file_size max_file_size: imageable_max_file_size
end end
end end

View File

@@ -22,7 +22,7 @@ module ImagesHelper
image.errors[:attachment].join(', ') if image.errors.key?(:attachment) image.errors[:attachment].join(', ') if image.errors.key?(:attachment)
end end
def image_bytesToMeg(bytes) def image_bytes_to_megabytes(bytes)
bytes / Numeric::MEGABYTE bytes / Numeric::MEGABYTE
end end

View File

@@ -1,11 +1,11 @@
module WelcomeHelper module WelcomeHelper
def active_class(index) def active_class(index)
"is-active is-in" if index == 0 "is-active is-in" if index.zero?
end end
def slide_display(index) def slide_display(index)
"display: none;" if index > 0 "display: none;" if index.positive?
end end
def recommended_path(recommended) def recommended_path(recommended)

View File

@@ -57,24 +57,24 @@ describe Poll::PartialResult do
expect(partial_result.amount_log).to eq("") expect(partial_result.amount_log).to eq("")
expect(partial_result.author_id_log).to eq("") expect(partial_result.author_id_log).to eq("")
author_A = create(:poll_officer).user author1 = create(:poll_officer).user
author_B = create(:poll_officer).user author2 = create(:poll_officer).user
author_C = create(:poll_officer).user author3 = create(:poll_officer).user
partial_result.amount = 33 partial_result.amount = 33
partial_result.author_id = author_A.id partial_result.author_id = author1.id
partial_result.save! partial_result.save!
partial_result.amount = 32 partial_result.amount = 32
partial_result.author_id = author_B.id partial_result.author_id = author2.id
partial_result.save! partial_result.save!
partial_result.amount = 34 partial_result.amount = 34
partial_result.author_id = author_C.id partial_result.author_id = author3.id
partial_result.save! partial_result.save!
expect(partial_result.amount_log).to eq(":33:32") expect(partial_result.amount_log).to eq(":33:32")
expect(partial_result.author_id_log).to eq(":#{author_A.id}:#{author_B.id}") expect(partial_result.author_id_log).to eq(":#{author1.id}:#{author2.id}")
end end
end end