diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5ce274570..142b66d7f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,11 +1,260 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2016-11-25 13:34:56 +0100 using RuboCop version 0.45.0. +# on 2017-07-07 21:23:30 +0200 using RuboCop version 0.49.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. +# Offense count: 45 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedHashRocketStyle, SupportedHashRocketStyles, EnforcedColonStyle, SupportedColonStyles, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/AlignHash: + Exclude: + - 'app/controllers/officing/results_controller.rb' + - 'spec/controllers/legislation/annotations_controller_spec.rb' + - 'spec/features/admin/banners_spec.rb' + +# Offense count: 50 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. +# SupportedStyles: with_first_parameter, with_fixed_indentation +Layout/AlignParameters: + Enabled: false + +# Offense count: 11 +# Cop supports --auto-correct. +Layout/ClosingParenthesisIndentation: + Exclude: + - 'spec/features/site_customization/custom_pages_spec.rb' + - 'spec/models/legislation/annotation_spec.rb' + - 'spec/rails_helper.rb' + +# Offense count: 51 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: leading, trailing +Layout/DotPosition: + Exclude: + - 'app/controllers/admin/poll/officer_assignments_controller.rb' + - 'app/controllers/admin/poll/polls_controller.rb' + - 'app/controllers/admin/poll/recounts_controller.rb' + - 'app/controllers/officing/final_recounts_controller.rb' + - 'app/controllers/officing/recounts_controller.rb' + - 'app/controllers/officing/residence_controller.rb' + - 'app/controllers/officing/results_controller.rb' + - 'app/models/poll/officer.rb' + - 'app/models/tag_cloud.rb' + - 'app/models/verification/management/managed_user.rb' + - 'lib/merged_comment_tree.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +Layout/EmptyLineAfterMagicComment: + Exclude: + - 'bin/rspec' + - 'bin/spring' + - 'spec/features/debates_spec.rb' + - 'spec/features/proposal_ballots_spec.rb' + - 'spec/features/proposals_spec.rb' + - 'spec/mailers/devise_mailer_spec.rb' + - 'spec/models/debate_spec.rb' + - 'spec/models/proposal_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/EmptyLines: + Exclude: + - 'app/controllers/admin/budget_investment_milestones_controller.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Layout/EmptyLinesAroundMethodBody: + Exclude: + - 'app/models/abilities/administrator.rb' + - 'lib/graph_ql/api_types_creator.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. +Layout/ExtraSpacing: + Exclude: + - 'spec/factories.rb' + - 'spec/models/proposal_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. +# SupportedStyles: consistent, special_for_inner_method_call, special_for_inner_method_call_in_parentheses +Layout/FirstParameterIndentation: + Exclude: + - 'app/controllers/users_controller.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: SupportedStyles, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_brackets +Layout/IndentArray: + EnforcedStyle: consistent + +# Offense count: 10 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_braces +Layout/IndentHash: + Exclude: + - 'spec/controllers/legislation/annotations_controller_spec.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent +Layout/IndentHeredoc: + Exclude: + - 'spec/factories.rb' + - 'spec/models/legislation/draft_version_spec.rb' + +# Offense count: 10 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: normal, rails +Layout/IndentationConsistency: + Exclude: + - 'spec/features/tracks_spec.rb' + - 'spec/models/budget/investment_spec.rb' + - 'spec/models/legislation/draft_version_spec.rb' + - 'spec/models/proposal_spec.rb' + +# Offense count: 23 +# Cop supports --auto-correct. +# Configuration parameters: Width, IgnoredPatterns. +Layout/IndentationWidth: + Enabled: false + +# Offense count: 7 +# Cop supports --auto-correct. +Layout/LeadingCommentSpace: + Exclude: + - 'Capfile' + - 'app/controllers/budgets/ballot/lines_controller.rb' + - 'spec/features/budgets/ballots_spec.rb' + - 'spec/features/comments/poll_questions_spec.rb' + - 'spec/features/officing/voters_spec.rb' + - 'spec/support/common_actions.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: symmetrical, new_line, same_line +Layout/MultilineArrayBraceLayout: + Exclude: + - 'app/controllers/valuation/budget_investments_controller.rb' + - 'app/controllers/valuation/spending_proposals_controller.rb' + - 'app/helpers/search_helper.rb' + +# Offense count: 9 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: symmetrical, new_line, same_line +Layout/MultilineHashBraceLayout: + Exclude: + - 'app/controllers/valuation/budget_investments_controller.rb' + - 'app/controllers/valuation/spending_proposals_controller.rb' + - 'app/models/budget/investment.rb' + - 'app/models/debate.rb' + - 'app/models/proposal.rb' + - 'app/models/spending_proposal.rb' + +# Offense count: 17 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: symmetrical, new_line, same_line +Layout/MultilineMethodCallBraceLayout: + Exclude: + - 'app/controllers/legislation/annotations_controller.rb' + - 'app/controllers/users_controller.rb' + - 'app/models/comment.rb' + - 'app/models/organization.rb' + - 'app/models/user.rb' + - 'spec/features/site_customization/custom_pages_spec.rb' + - 'spec/models/legislation/annotation_spec.rb' + - 'spec/rails_helper.rb' + +# Offense count: 71 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. +# SupportedStyles: aligned, indented, indented_relative_to_receiver +Layout/MultilineMethodCallIndentation: + Exclude: + - 'app/controllers/admin/poll/officer_assignments_controller.rb' + - 'app/controllers/admin/poll/polls_controller.rb' + - 'app/controllers/admin/poll/recounts_controller.rb' + - 'app/controllers/officing/final_recounts_controller.rb' + - 'app/controllers/officing/recounts_controller.rb' + - 'app/controllers/officing/residence_controller.rb' + - 'app/controllers/officing/results_controller.rb' + - 'app/models/poll/officer.rb' + - 'app/models/tag_cloud.rb' + - 'app/models/verification/management/managed_user.rb' + - 'lib/merged_comment_tree.rb' + - 'spec/models/comment_spec.rb' + - 'spec/models/debate_spec.rb' + - 'spec/models/proposal_spec.rb' + - 'spec/models/user_spec.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. +# SupportedStyles: aligned, indented +Layout/MultilineOperationIndentation: + Exclude: + - 'app/controllers/officing/results_controller.rb' + - 'app/helpers/users_helper.rb' + - 'app/helpers/valuation_helper.rb' + - 'app/models/user.rb' + - 'app/models/verification/letter.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/SpaceAfterColon: + Exclude: + - 'spec/features/admin/site_customization/pages_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment. +Layout/SpaceBeforeFirstArg: + Exclude: + - 'spec/factories.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Layout/SpaceInsideRangeLiteral: + Exclude: + - 'app/models/legislation/annotation.rb' + +# Offense count: 38 +Lint/AmbiguousBlockAssociation: + Exclude: + - 'spec/controllers/comments_controller_spec.rb' + - 'spec/controllers/debates_controller_spec.rb' + - 'spec/controllers/legislation/annotations_controller_spec.rb' + - 'spec/controllers/legislation/answers_controller_spec.rb' + - 'spec/lib/cache_spec.rb' + - 'spec/models/comment_spec.rb' + - 'spec/models/debate_spec.rb' + - 'spec/models/proposal_spec.rb' + - 'spec/models/user_spec.rb' + +# Offense count: 2 +Lint/HandleExceptions: + Exclude: + - 'app/controllers/legislation/annotations_controller.rb' + - 'spec/lib/graphql_spec.rb' + # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. @@ -14,79 +263,122 @@ Lint/InheritException: Exclude: - 'app/controllers/concerns/feature_flags.rb' -# Offense count: 13 +# Offense count: 1 +Lint/LiteralInCondition: + Exclude: + - 'app/models/budget/investment.rb' + +# Offense count: 51 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: 4 +# Offense count: 13 +# Cop supports --auto-correct. +Lint/StringConversionInInterpolation: + Exclude: + - 'app/models/poll/final_recount.rb' + - 'app/models/poll/null_result.rb' + - 'app/models/poll/partial_result.rb' + - 'app/models/poll/recount.rb' + - 'app/models/poll/white_result.rb' + +# Offense count: 15 # Cop supports --auto-correct. # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. Lint/UnusedBlockArgument: Exclude: - 'app/controllers/admin/spending_proposals_controller.rb' - 'app/models/ahoy/data_source.rb' + - 'lib/graph_ql/api_types_creator.rb' + - 'lib/graph_ql/query_type_creator.rb' + - 'spec/controllers/concerns/has_orders_spec.rb' + - 'spec/factories.rb' - 'spec/spec_helper.rb' -# Offense count: 5 +# Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods. Lint/UnusedMethodArgument: Exclude: - 'app/controllers/organizations/registrations_controller.rb' - - 'app/controllers/users/omniauth_callbacks_controller.rb' - 'app/controllers/users/registrations_controller.rb' + - 'app/mailers/mailer.rb' - 'app/models/abilities/everyone.rb' - - 'app/models/abilities/valuator.rb' -# Offense count: 135 +# Offense count: 278 Lint/UselessAssignment: Enabled: false -# Offense count: 41 -Metrics/AbcSize: - Max: 44 +# Offense count: 1 +Lint/Void: + Exclude: + - 'app/controllers/polls_controller.rb' -# Offense count: 4 +# Offense count: 74 +Metrics/AbcSize: + Max: 54 + +# Offense count: 454 +# Configuration parameters: CountComments, ExcludedMethods. +Metrics/BlockLength: + Max: 1071 + +# Offense count: 8 # Configuration parameters: CountComments. Metrics/ClassLength: - Max: 205 + Max: 256 -# Offense count: 5 +# Offense count: 10 Metrics/CyclomaticComplexity: - Max: 8 + Max: 10 -# Offense count: 52 -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives. -# URISchemes: http, https -Metrics/LineLength: - Max: 307 - -# Offense count: 28 +# Offense count: 53 # Configuration parameters: CountComments. Metrics/MethodLength: - Max: 38 + Max: 49 -# Offense count: 2 +# Offense count: 1 # Configuration parameters: CountComments. Metrics/ModuleLength: - Max: 193 + Max: 214 -# Offense count: 3 +# Offense count: 7 Metrics/PerceivedComplexity: Max: 11 -# Offense count: 4 +# Offense count: 6 # Cop supports --auto-correct. Performance/RedundantMatch: Exclude: + - 'app/controllers/valuation/budget_investments_controller.rb' - 'app/controllers/valuation/spending_proposals_controller.rb' - 'app/helpers/embed_videos_helper.rb' -# Offense count: 4 +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: NilOrEmpty, NotPresent, UnlessPresent. +Rails/Blank: + Exclude: + - 'app/controllers/management/base_controller.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Rails/Delegate: + Exclude: + - 'app/models/poll/question.rb' + +# Offense count: 5 # Cop supports --auto-correct. # Configuration parameters: Whitelist. # Whitelist: find_by_sql @@ -96,18 +388,38 @@ Rails/DynamicFindBy: - 'app/controllers/users/registrations_controller.rb' - 'spec/features/management/users_spec.rb' -# Offense count: 4 +# Offense count: 2 +Rails/FilePath: + Exclude: + - 'app/controllers/sandbox_controller.rb' + - 'spec/spec_helper.rb' + +# Offense count: 16 # Cop supports --auto-correct. # Configuration parameters: Include. # Include: app/models/**/*.rb Rails/FindBy: Exclude: + - 'app/models/budget/ballot.rb' + - 'app/models/geozone.rb' + - 'app/models/legislation/question.rb' + - 'app/models/officing/residence.rb' + - 'app/models/poll/voter.rb' - 'app/models/setting.rb' + - 'app/models/signature.rb' + - 'app/models/user.rb' - 'app/models/verification/email.rb' - 'app/models/verification/management/email.rb' - 'app/models/verification/residence.rb' -# Offense count: 24 +# Offense count: 1 +# Configuration parameters: Include. +# Include: app/models/**/*.rb +Rails/HasAndBelongsToMany: + Exclude: + - 'app/models/poll.rb' + +# Offense count: 37 # Cop supports --auto-correct. # Configuration parameters: Include. # Include: spec/**/*, test/**/* @@ -117,20 +429,40 @@ Rails/HttpPositionalArguments: - 'spec/controllers/concerns/has_filters_spec.rb' - 'spec/controllers/concerns/has_orders_spec.rb' - 'spec/controllers/debates_controller_spec.rb' + - 'spec/controllers/graphql_controller_spec.rb' + - 'spec/controllers/legislation/annotations_controller_spec.rb' + - 'spec/controllers/legislation/answers_controller_spec.rb' - 'spec/controllers/management/sessions_controller_spec.rb' - 'spec/controllers/pages_controller_spec.rb' - 'spec/controllers/users/registrations_controller_spec.rb' -# Offense count: 12 +# Offense count: 20 Rails/OutputSafety: Exclude: + - 'app/controllers/admin/legislation/draft_versions_controller.rb' + - 'app/controllers/admin/legislation/processes_controller.rb' + - 'app/controllers/admin/legislation/questions_controller.rb' + - 'app/controllers/budgets/investments_controller.rb' - 'app/controllers/spending_proposals_controller.rb' - 'app/helpers/application_helper.rb' - 'app/helpers/text_with_links_helper.rb' - 'app/helpers/users_helper.rb' - 'app/helpers/valuation_helper.rb' -# Offense count: 9 +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: NotNilAndNotEmpty, NotBlank, UnlessBlank. +Rails/Present: + Exclude: + - 'app/controllers/management/document_verifications_controller.rb' + +# Offense count: 70 +# Configuration parameters: Blacklist. +# Blacklist: decrement!, decrement_counter, increment!, increment_counter, toggle!, touch, update_all, update_attribute, update_column, update_columns, update_counters +Rails/SkipsModelValidations: + Enabled: false + +# Offense count: 10 Style/AccessorMethodName: Exclude: - 'app/controllers/application_controller.rb' @@ -138,34 +470,17 @@ Style/AccessorMethodName: - 'app/controllers/management/proposals_controller.rb' - 'app/controllers/management/spending_proposals_controller.rb' - 'app/controllers/proposals_controller.rb' + - 'lib/merged_comment_tree.rb' -# Offense count: 30 +# Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles. -# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit -Layout/AlignHash: +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: braces, no_braces, context_dependent +Style/BracesAroundHashParameters: Exclude: - - 'spec/features/admin/banners_spec.rb' + - 'app/models/concerns/searchable.rb' -# Offense count: 21 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. -# SupportedStyles: with_first_parameter, with_fixed_indentation -Layout/AlignParameters: - Exclude: - - 'app/helpers/search_helper.rb' - - 'app/models/verification/management/email.rb' - - 'bin/rspec' - - 'bin/spring' - - 'spec/features/admin/spending_proposals_spec.rb' - - 'spec/features/spending_proposals_spec.rb' - - 'spec/features/valuation/spending_proposals_spec.rb' - - 'spec/features/verification/verified_user_spec.rb' - - 'spec/i18n_spec.rb' - - 'spec/models/user_spec.rb' - - 'spec/rails_helper.rb' - -# Offense count: 57 +# Offense count: 119 # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: nested, compact Style/ClassAndModuleChildren: @@ -178,32 +493,28 @@ Style/ClassVars: - 'app/models/organization.rb' - 'app/models/user.rb' -# Offense count: 1 +# Offense count: 6 # Cop supports --auto-correct. -Layout/ClosingParenthesisIndentation: +Style/ColonMethodCall: Exclude: - - 'spec/rails_helper.rb' + - 'spec/models/budget/investment_spec.rb' -# Offense count: 4 +# Offense count: 12 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly. +# Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly, IncludeTernaryExpressions. # SupportedStyles: assign_to_condition, assign_inside_condition Style/ConditionalAssignment: Exclude: + - '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/comments_controller.rb' - 'app/controllers/management/spending_proposals_controller.rb' + - 'app/controllers/officing/final_recounts_controller.rb' + - 'app/controllers/officing/recounts_controller.rb' - 'app/controllers/spending_proposals_controller.rb' - 'app/controllers/verification/sms_controller.rb' - -# Offense count: 6 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: leading, trailing -Layout/DotPosition: - Exclude: - - 'app/models/banner.rb' - - 'app/models/tag_cloud.rb' - - 'app/models/verification/management/managed_user.rb' + - 'lib/graph_ql/api_types_creator.rb' # Offense count: 1 Style/DoubleNegation: @@ -216,79 +527,46 @@ Style/EmptyCaseCondition: Exclude: - 'app/models/concerns/verification.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. -# SupportedStyles: consistent, special_for_inner_method_call, special_for_inner_method_call_in_parentheses -Layout/FirstParameterIndentation: +# Offense count: 2 +# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms. +# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS +Style/FileName: Exclude: - - 'app/controllers/users_controller.rb' + - 'Capfile' + - 'Gemfile' -# Offense count: 32 +# Offense count: 56 # Configuration parameters: MinBodyLength. Style/GuardClause: Enabled: false -# Offense count: 6 +# Offense count: 12 # Cop supports --auto-correct. # Configuration parameters: MaxLineLength. Style/IfUnlessModifier: Exclude: - 'app/controllers/annotations_controller.rb' + - 'app/controllers/application_controller.rb' + - 'app/controllers/graphql_controller.rb' + - 'app/controllers/legislation/annotations_controller.rb' + - 'app/controllers/valuation/budget_investments_controller.rb' - 'app/controllers/verification/letter_controller.rb' - 'app/controllers/welcome_controller.rb' - 'app/helpers/embed_videos_helper.rb' + - 'app/mailers/mailer.rb' - 'app/models/proposal.rb' - 'app/models/spending_proposal.rb' -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: SupportedStyles, IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_brackets -Layout/IndentArray: - EnforcedStyle: consistent - # Offense count: 4 # Cop supports --auto-correct. -# Configuration parameters: SupportedStyles, IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_braces -Layout/IndentHash: - EnforcedStyle: consistent - -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: normal, rails -Layout/IndentationConsistency: - Exclude: - - 'spec/features/tracks_spec.rb' - - 'spec/models/proposal_spec.rb' - -# Offense count: 11 -# Cop supports --auto-correct. -# Configuration parameters: Width. -Layout/IndentationWidth: - Exclude: - - 'app/controllers/annotations_controller.rb' - - 'app/helpers/flags_helper.rb' - - 'app/mailers/devise_mailer.rb' - - 'app/mailers/mailer.rb' - - 'app/models/ahoy/data_source.rb' - - 'app/models/comment_notifier.rb' - - 'app/models/concerns/search_cache.rb' - - 'spec/features/comments/proposals_spec.rb' - - 'spec/features/moderation/users_spec.rb' - - 'spec/features/tracks_spec.rb' - - 'spec/features/verification/verified_user_spec.rb' - -# Offense count: 2 -# Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: line_count_dependent, lambda, literal Style/Lambda: Exclude: - - 'app/models/banner.rb' + - 'app/models/comment.rb' - 'app/models/direct_message.rb' + - 'app/models/vote.rb' + - 'lib/graph_ql/api_types_creator.rb' # Offense count: 1 # Cop supports --auto-correct. @@ -304,101 +582,58 @@ Style/MethodDefParentheses: Exclude: - 'spec/helpers/comments_helper_spec.rb' -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: symmetrical, new_line, same_line -Layout/MultilineArrayBraceLayout: - Exclude: - - 'app/controllers/valuation/spending_proposals_controller.rb' - - 'app/helpers/search_helper.rb' - # Offense count: 1 Style/MultilineBlockChain: Exclude: - 'app/controllers/valuation/spending_proposals_controller.rb' -# Offense count: 2 -# Cop supports --auto-correct. -Layout/MultilineBlockLayout: - Exclude: - - 'app/models/banner.rb' - - 'spec/features/users_auth_spec.rb' - -# Offense count: 6 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: symmetrical, new_line, same_line -Layout/MultilineHashBraceLayout: - Exclude: - - 'app/controllers/valuation/spending_proposals_controller.rb' - - 'app/models/debate.rb' - - 'app/models/proposal.rb' - - 'app/models/spending_proposal.rb' - -# Offense count: 2 +# Offense count: 1 # Cop supports --auto-correct. Style/MultilineIfThen: Exclude: - 'app/controllers/management/users_controller.rb' - - 'lib/census_api.rb' -# Offense count: 6 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: symmetrical, new_line, same_line -Layout/MultilineMethodCallBraceLayout: - Exclude: - - 'app/controllers/users_controller.rb' - - 'app/models/comment.rb' - - 'app/models/organization.rb' - - 'app/models/user.rb' - - 'spec/rails_helper.rb' - -# Offense count: 33 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. -# SupportedStyles: aligned, indented, indented_relative_to_receiver -Layout/MultilineMethodCallIndentation: - Exclude: - - 'app/models/banner.rb' - - 'app/models/tag_cloud.rb' - - 'app/models/verification/management/managed_user.rb' - - 'spec/models/comment_spec.rb' - - 'spec/models/debate_spec.rb' - - 'spec/models/proposal_spec.rb' - - 'spec/models/user_spec.rb' - -# Offense count: 5 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. -# SupportedStyles: aligned, indented -Layout/MultilineOperationIndentation: - Exclude: - - 'app/helpers/users_helper.rb' - - 'app/helpers/valuation_helper.rb' - - 'app/models/verification/letter.rb' - -# Offense count: 5 +# Offense count: 15 # Cop supports --auto-correct. Style/MutableConstant: Exclude: - 'app/models/activity.rb' + - 'app/models/budget/reclassified_vote.rb' + - 'app/models/legislation/draft_version.rb' + - 'app/models/poll/null_result.rb' + - 'app/models/poll/partial_result.rb' + - 'app/models/poll/white_result.rb' - 'app/models/proposal.rb' + - 'app/models/signature_sheet.rb' + - 'app/models/site_customization/content_block.rb' + - 'app/models/site_customization/image.rb' + - 'app/models/site_customization/page.rb' + - 'lib/graph_ql/api_types_creator.rb' - 'lib/tag_sanitizer.rb' - 'lib/wysiwyg_sanitizer.rb' -# Offense count: 17 +# Offense count: 29 # Cop supports --auto-correct. Style/NestedParenthesizedCalls: Exclude: - 'spec/features/debates_spec.rb' + - 'spec/features/emails_spec.rb' + - 'spec/features/valuation/budget_investments_spec.rb' - 'spec/features/valuation/spending_proposals_spec.rb' - 'spec/helpers/settings_helper_spec.rb' - 'spec/helpers/verification_helper_spec.rb' -# Offense count: 12 +# Offense count: 1 # Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles. +# SupportedStyles: skip_modifier_ifs, always +Style/Next: + Exclude: + - 'app/controllers/officing/results_controller.rb' + +# Offense count: 54 +# Cop supports --auto-correct. +# Configuration parameters: Strict. Style/NumericLiterals: MinDigits: 9 @@ -414,9 +649,9 @@ Style/NumericPredicate: - 'app/helpers/banners_helper.rb' - 'app/helpers/debates_helper.rb' - 'app/helpers/votes_helper.rb' + - 'app/models/budget/ballot.rb' - 'app/models/concerns/conflictable.rb' - 'app/models/concerns/taggable.rb' - - 'app/models/concerns/verification.rb' - 'app/models/debate.rb' - 'app/models/lock.rb' - 'app/models/user.rb' @@ -439,7 +674,7 @@ Style/ParenthesesAroundCondition: - 'app/models/debate.rb' - 'app/models/proposal.rb' -# Offense count: 6 +# Offense count: 11 # Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist. # NamePrefix: is_, has_, have_ # NamePrefixBlacklist: is_, has_, have_ @@ -451,10 +686,11 @@ Style/PredicateName: - 'app/controllers/concerns/has_orders.rb' - 'app/helpers/banners_helper.rb' - 'app/helpers/debates_helper.rb' + - 'app/models/budget/ballot.rb' - 'app/models/user.rb' - 'lib/census_api.rb' -# Offense count: 3 +# Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: compact, exploded @@ -462,18 +698,20 @@ Style/RaiseArgs: Exclude: - 'app/controllers/management/base_controller.rb' - 'app/controllers/users/omniauth_callbacks_controller.rb' + - 'app/controllers/valuation/budget_investments_controller.rb' - 'app/controllers/valuation/spending_proposals_controller.rb' -# Offense count: 16 +# Offense count: 2 +# Cop supports --auto-correct. +Style/RedundantBegin: + Exclude: + - 'app/controllers/graphql_controller.rb' + - 'app/models/legislation/annotation.rb' + +# Offense count: 55 # Cop supports --auto-correct. Style/RedundantParentheses: - Exclude: - - 'app/controllers/admin/settings_controller.rb' - - 'app/helpers/proposals_helper.rb' - - 'spec/features/admin/organizations_spec.rb' - - 'spec/features/debates_spec.rb' - - 'spec/features/proposals_spec.rb' - - 'spec/models/debate_spec.rb' + Enabled: false # Offense count: 3 # Cop supports --auto-correct. @@ -484,43 +722,54 @@ Style/RegexpLiteral: - 'app/helpers/embed_videos_helper.rb' - 'spec/customization_engine_spec.rb' -# Offense count: 2 +# Offense count: 6 # Cop supports --auto-correct. Style/RescueModifier: Exclude: - - 'app/controllers/concerns/commentable_actions.rb' + - 'app/controllers/budgets/investments_controller.rb' + - 'app/controllers/concerns/search.rb' - 'app/controllers/verification/sms_controller.rb' + - 'app/models/concerns/measurable.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: ConvertCodeThatCanStartToReturnNil. +Style/SafeNavigation: + Exclude: + - 'app/models/signature.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiteralsInInterpolation: + Exclude: + - 'spec/features/budgets/investments_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline, SupportedStylesForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInArguments: + Exclude: + - 'app/controllers/legislation/answers_controller.rb' # Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: IgnoredMethods. -# IgnoredMethods: respond_to, define_method -Style/SymbolProc: - Exclude: - - 'app/controllers/admin/settings_controller.rb' - - 'app/controllers/notifications_controller.rb' - - 'app/controllers/organizations/registrations_controller.rb' - - 'lib/manager_authenticator.rb' - - 'spec/factories.rb' - -# Offense count: 13 # Configuration parameters: SupportedStyles. +# SupportedStyles: snake_case, camelCase +Style/VariableName: + EnforcedStyle: snake_case + +# Offense count: 107 +# Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: snake_case, normalcase, non_integer Style/VariableNumber: - EnforcedStyle: normalcase + Enabled: false -# Offense count: 9 +# Offense count: 31 # Cop supports --auto-correct. # Configuration parameters: SupportedStyles, WordRegex. # SupportedStyles: percent, brackets Style/WordArray: EnforcedStyle: percent - MinSize: 3 - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: braces, no_braces, context_dependent -Style/BracesAroundHashParameters: - Exclude: - - 'app/models/concerns/searchable.rb' + MinSize: 9 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 65c05c574..e4bc6af67 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,22 +1,74 @@ -# Contributor Code of Conduct +# Contributor Covenant Code of Conduct -As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. +## Our Pledge -We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality. +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery -* Personal attacks -* Trolling or insulting/derogatory comments +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment -* Publishing other's private information, such as physical or electronic addresses, without explicit permission -* Other unethical or unprofessional conduct. +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting -Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team. +## Our Responsibilities -This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers. +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. -This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/) \ No newline at end of file +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at consul@madrid.es. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/Gemfile b/Gemfile index 0f00da1ba..678845e36 100644 --- a/Gemfile +++ b/Gemfile @@ -1,117 +1,91 @@ source 'https://rubygems.org' -# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.9' -# Use PostgreSQL -gem 'pg', '~> 0.20.0' -# Use SCSS for stylesheets -gem 'sass-rails', '~> 5.0', '>= 5.0.4' -# Use Uglifier as compressor for JavaScript assets -gem 'uglifier', '~> 3.2.0' -# Use CoffeeScript for .coffee assets and views -gem 'coffee-rails', '~> 4.2.1' -# See https://github.com/rails/execjs#readme for more supported runtimes -# gem 'therubyracer', platforms: :ruby -# Use jquery as the JavaScript library -gem 'jquery-rails', '~> 4.3.1' -gem 'jquery-ui-rails' -# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks -gem 'turbolinks' - -# Fix sprockets on the -gem 'sprockets', '~> 3.7.1' - -gem 'devise', '~> 3.5.7' -gem 'devise_security_extension' -# Use ActiveModel has_secure_password -# gem 'bcrypt', '~> 3.1.7' -gem 'omniauth' -gem 'omniauth-twitter' -gem 'omniauth-facebook', '~> 4.0.0' -gem 'omniauth-google-oauth2', '~> 0.4.0' - -gem 'kaminari', '~> 1.0.1' +gem 'acts-as-taggable-on', '~> 4.0.0' +gem 'acts_as_votable', '~> 0.10.0' +gem 'ahoy_matey', '~> 1.6.0' gem 'ancestry', '~> 2.2.2' -gem 'acts-as-taggable-on' -gem 'responders', '~> 2.4.0' +gem 'browser', '~> 2.3.0' +gem 'cancancan', '~> 1.16.0' +gem 'ckeditor', '~> 4.2.3' +gem 'cocoon', '~> 1.2.9' +gem 'coffee-rails', '~> 4.2.1' +gem 'daemons', '~> 1.2.4' +gem 'dalli', '~> 2.7.6' +gem 'delayed_job_active_record', '~> 4.1.0' +gem 'devise', '~> 3.5.7' +gem 'devise-async', '~> 0.10.2' +gem 'devise_security_extension', '~> 0.10.0' gem 'foundation-rails', '~> 6.2.4.0' gem 'foundation_rails_helper', '~> 2.0.0' -gem 'acts_as_votable' -gem 'ckeditor', '~> 4.2.3' -gem 'invisible_captcha', '~> 0.9.2' -gem 'cancancan', '~> 1.16.0' -gem 'social-share-button', '~> 0.10' -gem 'initialjs-rails', '0.2.0.4' -gem 'unicorn', '~> 5.3.0' -gem 'paranoia', '~> 2.3.1' -gem 'rinku', '~> 2.0.2', require: 'rails_rinku' -gem 'savon' -gem 'dalli' -gem 'rollbar', '~> 2.14.1' -gem 'delayed_job_active_record', '~> 4.1.0' -gem 'daemons' -gem 'devise-async' -gem 'newrelic_rpm', '~> 4.1.0.333' -gem 'whenever', require: false -gem 'pg_search' -gem 'sitemap_generator', '~> 5.3.1' - -gem 'ahoy_matey', '~> 1.6.0' -gem 'groupdate', '~> 3.2.0' # group temporary data -gem 'tolk', '~> 2.0.0' # Web interface for translations - -gem 'browser' -gem 'turnout', '~> 2.4.0' -gem 'redcarpet', '~> 3.4.0' -gem 'rubyzip', '~> 1.2.0' - -gem 'paperclip' -gem 'rails-assets-markdown-it', source: 'https://rails-assets.org' - -gem 'cocoon' - -gem 'graphql', '~> 1.6.3' gem 'graphiql-rails', '~> 1.4.1' +gem 'graphql', '~> 1.6.3' +gem 'groupdate', '~> 3.2.0' +gem 'initialjs-rails', '~> 0.2.0.5' +gem 'invisible_captcha', '~> 0.9.2' +gem 'jquery-rails', '~> 4.3.1' +gem 'jquery-ui-rails', '~> 6.0.1' +gem 'kaminari', '~> 1.0.1' +gem 'newrelic_rpm', '~> 4.1.0.333' +gem 'omniauth', '~> 1.6.1' +gem 'omniauth-facebook', '~> 4.0.0' +gem 'omniauth-google-oauth2', '~> 0.4.0' +gem 'omniauth-twitter', '~> 1.4.0' +gem 'paperclip', '~> 5.1.0' +gem 'paranoia', '~> 2.3.1' +gem 'pg', '~> 0.20.0' +gem 'pg_search', '~> 2.0.1' +gem 'rails-assets-markdown-it', '~> 8.2.1', source: 'https://rails-assets.org' +gem 'redcarpet', '~> 3.4.0' +gem 'responders', '~> 2.4.0' +gem 'rinku', '~> 2.0.2', require: 'rails_rinku' +gem 'rollbar', '~> 2.14.1' +gem 'rubyzip', '~> 1.2.0' +gem 'sass-rails', '~> 5.0', '>= 5.0.4' +gem 'savon', '~> 2.11.1' +gem 'sitemap_generator', '~> 5.3.1' +gem 'social-share-button', '~> 0.10' +gem 'sprockets', '~> 3.7.1' +gem 'turbolinks', '~> 2.5.3' +gem 'turnout', '~> 2.4.0' +gem 'uglifier', '~> 3.2.0' +gem 'unicorn', '~> 5.3.0' +gem 'whenever', '~> 0.9.7', require: false group :development, :test do - # Call 'byebug' anywhere in the code to stop execution and get a debugger console - gem 'byebug' - # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring - gem 'spring' - gem 'spring-commands-rspec' - gem 'rspec-rails', '~> 3.6' - gem 'capybara', '~> 2.14.0' - gem 'factory_girl_rails', '~> 4.8.0' - gem 'fuubar' - gem 'launchy' - gem 'quiet_assets' - gem 'letter_opener_web', '~> 1.3.1' - gem 'i18n-tasks', '~> 0.9.15' - gem 'capistrano', '~> 3.8.1', require: false - gem 'capistrano-bundler', '~> 1.2', require: false - gem "capistrano-rails", '~> 1.2.3', require: false - gem 'rvm1-capistrano3', require: false - gem 'capistrano3-delayed-job', '~> 1.7.3' gem "bullet", '~> 5.5.1' + gem 'byebug', '~> 9.0.6' + gem 'factory_girl_rails', '~> 4.8.0' gem "faker", '~> 1.7.3' + gem 'i18n-tasks', '~> 0.9.15' + gem 'knapsack', '~> 1.13.3' + gem 'launchy', '~> 2.4.3' + gem 'letter_opener_web', '~> 1.3.1' + gem 'quiet_assets', '~> 1.1.0' gem 'rubocop', '~> 0.49.1', require: false - gem 'knapsack' + gem 'spring', '~> 2.0.1' + gem 'spring-commands-rspec', '~> 1.0.4' end group :test do - gem 'database_cleaner' - gem 'poltergeist', '~> 1.15.0' + gem 'capybara', '~> 2.14.0' gem 'coveralls', '~> 0.8.21', require: false - gem 'email_spec' + gem 'database_cleaner', '~> 1.5.3' + gem 'email_spec', '~> 2.1.0' + gem 'poltergeist', '~> 1.15.0' + gem 'rspec-rails', '~> 3.6' end group :development do - gem 'mdl', require: false - # Access an IRB console on exception pages or by using <%= console %> in views - gem 'scss_lint', require: false - gem 'web-console', '3.3.0' - + gem 'capistrano', '~> 3.8.1', require: false + gem 'capistrano-bundler', '~> 1.2', require: false + gem "capistrano-rails", '~> 1.2.3', require: false + gem 'capistrano3-delayed-job', '~> 1.7.3' + gem 'mdl', '~> 0.4.0', require: false + gem 'rvm1-capistrano3', '~> 1.4.0', require: false + gem 'scss_lint', '~> 0.53.0', require: false + gem 'web-console', '~> 3.3.0' end eval_gemfile './Gemfile_custom' diff --git a/Gemfile.lock b/Gemfile.lock index de9002e3a..f2a314780 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -170,9 +170,6 @@ GEM activesupport (>= 4.1) railties (>= 4.1) tzinfo (~> 1.2, >= 1.2.2) - fuubar (2.2.0) - rspec-core (~> 3.0) - ruby-progressbar (~> 1.4) geocoder (1.4.3) globalid (0.4.0) activesupport (>= 4.2.0) @@ -199,7 +196,7 @@ GEM parser (>= 2.2.3.0) rainbow (~> 2.2) terminal-table (>= 1.5.1) - initialjs-rails (0.2.0.4) + initialjs-rails (0.2.0.5) railties (>= 3.1, < 6.0) invisible_captcha (0.9.2) rails (>= 3.2.0) @@ -387,7 +384,6 @@ GEM rvm1-capistrano3 (1.4.0) capistrano (~> 3.0) sshkit (>= 1.2) - safe_yaml (1.0.4) safely_block (0.2.0) errbase sass (3.4.23) @@ -445,9 +441,6 @@ GEM tilt (2.0.7) timecop (0.8.1) tins (1.13.2) - tolk (2.0.0) - rails (>= 4.0) - safe_yaml (>= 0.8.6) turbolinks (2.5.3) coffee-rails turnout (2.4.0) @@ -487,13 +480,13 @@ PLATFORMS ruby DEPENDENCIES - acts-as-taggable-on - acts_as_votable + acts-as-taggable-on (~> 4.0.0) + acts_as_votable (~> 0.10.0) ahoy_matey (~> 1.6.0) ancestry (~> 2.2.2) - browser + browser (~> 2.3.0) bullet (~> 5.5.1) - byebug + byebug (~> 9.0.6) cancancan (~> 1.16.0) capistrano (~> 3.8.1) capistrano-bundler (~> 1.2) @@ -501,48 +494,47 @@ DEPENDENCIES capistrano3-delayed-job (~> 1.7.3) capybara (~> 2.14.0) ckeditor (~> 4.2.3) - cocoon + cocoon (~> 1.2.9) coffee-rails (~> 4.2.1) coveralls (~> 0.8.21) - daemons - dalli - database_cleaner + daemons (~> 1.2.4) + dalli (~> 2.7.6) + database_cleaner (~> 1.5.3) delayed_job_active_record (~> 4.1.0) devise (~> 3.5.7) - devise-async - devise_security_extension - email_spec + devise-async (~> 0.10.2) + devise_security_extension (~> 0.10.0) + email_spec (~> 2.1.0) factory_girl_rails (~> 4.8.0) faker (~> 1.7.3) foundation-rails (~> 6.2.4.0) foundation_rails_helper (~> 2.0.0) - fuubar graphiql-rails (~> 1.4.1) graphql (~> 1.6.3) groupdate (~> 3.2.0) i18n-tasks (~> 0.9.15) - initialjs-rails (= 0.2.0.4) + initialjs-rails (~> 0.2.0.5) invisible_captcha (~> 0.9.2) jquery-rails (~> 4.3.1) - jquery-ui-rails + jquery-ui-rails (~> 6.0.1) kaminari (~> 1.0.1) - knapsack - launchy + knapsack (~> 1.13.3) + launchy (~> 2.4.3) letter_opener_web (~> 1.3.1) - mdl + mdl (~> 0.4.0) newrelic_rpm (~> 4.1.0.333) - omniauth + omniauth (~> 1.6.1) omniauth-facebook (~> 4.0.0) omniauth-google-oauth2 (~> 0.4.0) - omniauth-twitter - paperclip + omniauth-twitter (~> 1.4.0) + paperclip (~> 5.1.0) paranoia (~> 2.3.1) pg (~> 0.20.0) - pg_search + pg_search (~> 2.0.1) poltergeist (~> 1.15.0) - quiet_assets + quiet_assets (~> 1.1.0) rails (= 4.2.9) - rails-assets-markdown-it! + rails-assets-markdown-it (~> 8.2.1)! redcarpet (~> 3.4.0) responders (~> 2.4.0) rinku (~> 2.0.2) @@ -550,22 +542,21 @@ DEPENDENCIES rspec-rails (~> 3.6) rubocop (~> 0.49.1) rubyzip (~> 1.2.0) - rvm1-capistrano3 + rvm1-capistrano3 (~> 1.4.0) sass-rails (~> 5.0, >= 5.0.4) - savon - scss_lint + savon (~> 2.11.1) + scss_lint (~> 0.53.0) sitemap_generator (~> 5.3.1) social-share-button (~> 0.10) - spring - spring-commands-rspec + spring (~> 2.0.1) + spring-commands-rspec (~> 1.0.4) sprockets (~> 3.7.1) - tolk (~> 2.0.0) - turbolinks + turbolinks (~> 2.5.3) turnout (~> 2.4.0) uglifier (~> 3.2.0) unicorn (~> 5.3.0) - web-console (= 3.3.0) - whenever + web-console (~> 3.3.0) + whenever (~> 0.9.7) BUNDLED WITH 1.15.1 diff --git a/app/assets/stylesheets/annotator_overrides.scss b/app/assets/stylesheets/annotator_overrides.scss index c2cbe68ff..fcc127ecd 100644 --- a/app/assets/stylesheets/annotator_overrides.scss +++ b/app/assets/stylesheets/annotator_overrides.scss @@ -132,7 +132,7 @@ background: hsla(51, 91, 75, 0.5); .weight-4 { - background: hsla(51, 91, 75, 0.75); + background: hsla(51, 91, 75, 0.75); } } diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 96c81c001..b4ea0cca3 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -236,6 +236,11 @@ a { border-bottom: 2px solid $brand; color: $brand; } + + &.bold { + font-weight: bold; + color: $brand; + } } &.no-margin-top { diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 843d49498..4b64fdc2e 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -23,9 +23,11 @@ class AccountController < ApplicationController def account_params if @account.organization? - params.require(:account).permit(:phone_number, :email_on_comment, :email_on_comment_reply, :newsletter, organization_attributes: [:name, :responsible_name]) + params.require(:account).permit(:phone_number, :email_on_comment, :email_on_comment_reply, :newsletter, + organization_attributes: [:name, :responsible_name]) else - params.require(:account).permit(:username, :public_activity, :public_interests, :email_on_comment, :email_on_comment_reply, :email_on_direct_message, :email_digest, :newsletter, :official_position_badge) + params.require(:account).permit(:username, :public_activity, :public_interests, :email_on_comment, :email_on_comment_reply, + :email_on_direct_message, :email_digest, :newsletter, :official_position_badge) end end diff --git a/app/controllers/admin/budgets_controller.rb b/app/controllers/admin/budgets_controller.rb index b37351028..7caf4f35c 100644 --- a/app/controllers/admin/budgets_controller.rb +++ b/app/controllers/admin/budgets_controller.rb @@ -20,7 +20,7 @@ class Admin::BudgetsController < Admin::BaseController def calculate_winners return unless @budget.balloting_process? - @budget.headings.each { |heading| Budget::Result.new(@budget, heading).calculate_winners } + @budget.headings.each { |heading| Budget::Result.new(@budget, heading).delay.calculate_winners } redirect_to admin_budget_budget_investments_path(budget_id: @budget.id, filter: 'winners'), notice: I18n.t("admin.budgets.winners.calculated") end diff --git a/app/controllers/admin/legislation/draft_versions_controller.rb b/app/controllers/admin/legislation/draft_versions_controller.rb index 0d84addbf..914745ba0 100644 --- a/app/controllers/admin/legislation/draft_versions_controller.rb +++ b/app/controllers/admin/legislation/draft_versions_controller.rb @@ -8,7 +8,8 @@ class Admin::Legislation::DraftVersionsController < Admin::Legislation::BaseCont def create if @draft_version.save - redirect_to admin_legislation_process_draft_versions_path, notice: t('admin.legislation.draft_versions.create.notice', link: legislation_process_draft_version_path(@process, @draft_version).html_safe) + link = legislation_process_draft_version_path(@process, @draft_version).html_safe + redirect_to admin_legislation_process_draft_versions_path, notice: t('admin.legislation.draft_versions.create.notice', link: link) else flash.now[:error] = t('admin.legislation.draft_versions.create.error') render :new @@ -17,7 +18,9 @@ class Admin::Legislation::DraftVersionsController < Admin::Legislation::BaseCont def update if @draft_version.update(draft_version_params) - redirect_to edit_admin_legislation_process_draft_version_path(@process, @draft_version), notice: t('admin.legislation.draft_versions.update.notice', link: legislation_process_draft_version_path(@process, @draft_version).html_safe) + link = legislation_process_draft_version_path(@process, @draft_version).html_safe + notice = t('admin.legislation.draft_versions.update.notice', link: link) + redirect_to edit_admin_legislation_process_draft_version_path(@process, @draft_version), notice: notice else flash.now[:error] = t('admin.legislation.draft_versions.update.error') render :edit diff --git a/app/controllers/admin/legislation/processes_controller.rb b/app/controllers/admin/legislation/processes_controller.rb index fb4e8ee3f..5d8d828cd 100644 --- a/app/controllers/admin/legislation/processes_controller.rb +++ b/app/controllers/admin/legislation/processes_controller.rb @@ -9,7 +9,8 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll def create if @process.save - redirect_to edit_admin_legislation_process_path(@process), notice: t('admin.legislation.processes.create.notice', link: legislation_process_path(@process).html_safe) + link = legislation_process_path(@process).html_safe + redirect_to edit_admin_legislation_process_path(@process), notice: t('admin.legislation.processes.create.notice', link: link) else flash.now[:error] = t('admin.legislation.processes.create.error') render :new @@ -18,7 +19,8 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll def update if @process.update(process_params) - redirect_to edit_admin_legislation_process_path(@process), notice: t('admin.legislation.processes.update.notice', link: legislation_process_path(@process).html_safe) + link = legislation_process_path(@process).html_safe + redirect_to edit_admin_legislation_process_path(@process), notice: t('admin.legislation.processes.update.notice', link: link) else flash.now[:error] = t('admin.legislation.processes.update.error') render :edit diff --git a/app/controllers/admin/legislation/questions_controller.rb b/app/controllers/admin/legislation/questions_controller.rb index c8335e6df..054e3e353 100644 --- a/app/controllers/admin/legislation/questions_controller.rb +++ b/app/controllers/admin/legislation/questions_controller.rb @@ -13,7 +13,8 @@ class Admin::Legislation::QuestionsController < Admin::Legislation::BaseControll def create @question.author = current_user if @question.save - redirect_to admin_legislation_process_questions_path, notice: t('admin.legislation.questions.create.notice', link: legislation_process_question_path(@process, @question).html_safe) + notice = t('admin.legislation.questions.create.notice', link: legislation_process_question_path(@process, @question).html_safe) + redirect_to admin_legislation_process_questions_path, notice: notice else flash.now[:error] = t('admin.legislation.questions.create.error') render :new @@ -22,7 +23,8 @@ class Admin::Legislation::QuestionsController < Admin::Legislation::BaseControll def update if @question.update(question_params) - redirect_to edit_admin_legislation_process_question_path(@process, @question), notice: t('admin.legislation.questions.update.notice', link: legislation_process_question_path(@process, @question).html_safe) + notice = t('admin.legislation.questions.update.notice', link: legislation_process_question_path(@process, @question).html_safe) + redirect_to edit_admin_legislation_process_question_path(@process, @question), notice: notice else flash.now[:error] = t('admin.legislation.questions.update.error') render :edit diff --git a/app/controllers/admin/poll/booth_assignments_controller.rb b/app/controllers/admin/poll/booth_assignments_controller.rb index f81382bf8..4eb591d02 100644 --- a/app/controllers/admin/poll/booth_assignments_controller.rb +++ b/app/controllers/admin/poll/booth_assignments_controller.rb @@ -15,12 +15,14 @@ class Admin::Poll::BoothAssignmentsController < Admin::BaseController end def show - @booth_assignment = @poll.booth_assignments.includes(:recounts, :final_recounts, :voters, officer_assignments: [officer: [:user]]).find(params[:id]) + @booth_assignment = @poll.booth_assignments.includes(:recounts, :final_recounts, :voters, + officer_assignments: [officer: [:user]]).find(params[:id]) @voters_by_date = @booth_assignment.voters.group_by {|v| v.created_at.to_date} end def create - @booth_assignment = ::Poll::BoothAssignment.new(poll_id: booth_assignment_params[:poll_id], booth_id: booth_assignment_params[:booth_id]) + @booth_assignment = ::Poll::BoothAssignment.new(poll_id: booth_assignment_params[:poll_id], + booth_id: booth_assignment_params[:booth_id]) if @booth_assignment.save notice = t("admin.poll_booth_assignments.flash.create") @@ -63,4 +65,4 @@ class Admin::Poll::BoothAssignmentsController < Admin::BaseController @search = search_params[:search] end -end \ No newline at end of file +end diff --git a/app/controllers/admin/poll/officer_assignments_controller.rb b/app/controllers/admin/poll/officer_assignments_controller.rb index f37ef9ab8..07f206f92 100644 --- a/app/controllers/admin/poll/officer_assignments_controller.rb +++ b/app/controllers/admin/poll/officer_assignments_controller.rb @@ -43,7 +43,9 @@ class Admin::Poll::OfficerAssignmentsController < Admin::BaseController else notice = t("admin.poll_officer_assignments.flash.error_create") end - redirect_to by_officer_admin_poll_officer_assignments_path(poll_id: create_params[:poll_id], officer_id: create_params[:officer_id]), notice: notice + + redirect_params = { poll_id: create_params[:poll_id], officer_id: create_params[:officer_id] } + redirect_to by_officer_admin_poll_officer_assignments_path(redirect_params), notice: notice end def destroy @@ -54,7 +56,9 @@ class Admin::Poll::OfficerAssignmentsController < Admin::BaseController else notice = t("admin.poll_officer_assignments.flash.error_destroy") end - redirect_to by_officer_admin_poll_officer_assignments_path(poll_id: @officer_assignment.poll_id, officer_id: @officer_assignment.officer_id), notice: notice + + redirect_params = { poll_id: @officer_assignment.poll_id, officer_id: @officer_assignment.officer_id } + redirect_to by_officer_admin_poll_officer_assignments_path(redirect_params), notice: notice end private @@ -68,7 +72,8 @@ class Admin::Poll::OfficerAssignmentsController < Admin::BaseController end def load_booth_assignment - @booth_assignment = ::Poll::BoothAssignment.includes(:poll).find_by(poll_id: create_params[:poll_id], booth_id: create_params[:booth_id]) + find_params = { poll_id: create_params[:poll_id], booth_id: create_params[:booth_id] } + @booth_assignment = ::Poll::BoothAssignment.includes(:poll).find_by(find_params) end def load_poll @@ -89,4 +94,4 @@ class Admin::Poll::OfficerAssignmentsController < Admin::BaseController @search = search_params[:search] end -end \ No newline at end of file +end diff --git a/app/controllers/admin/spending_proposals_controller.rb b/app/controllers/admin/spending_proposals_controller.rb index b5923f2f6..899a32486 100644 --- a/app/controllers/admin/spending_proposals_controller.rb +++ b/app/controllers/admin/spending_proposals_controller.rb @@ -7,7 +7,9 @@ class Admin::SpendingProposalsController < Admin::BaseController load_and_authorize_resource def index - @spending_proposals = SpendingProposal.scoped_filter(params, @current_filter).order(cached_votes_up: :desc, created_at: :desc).page(params[:page]) + @spending_proposals = SpendingProposal.scoped_filter(params, @current_filter) + .order(cached_votes_up: :desc, created_at: :desc) + .page(params[:page]) end def show @@ -33,13 +35,15 @@ class Admin::SpendingProposalsController < Admin::BaseController def summary @spending_proposals = SpendingProposal.group(:geozone).sum(:price).sort_by{|geozone, count| geozone.present? ? geozone.name : "z"} - @spending_proposals_with_supports = SpendingProposal.with_supports.group(:geozone).sum(:price).sort_by{|geozone, count| geozone.present? ? geozone.name : "z"} + @spending_proposals_with_supports = SpendingProposal.with_supports.group(:geozone).sum(:price) + .sort_by{|geozone, count| geozone.present? ? geozone.name : "z"} end private def spending_proposal_params - params.require(:spending_proposal).permit(:title, :description, :external_url, :geozone_id, :association_name, :administrator_id, :tag_list, valuator_ids: []) + params.require(:spending_proposal).permit(:title, :description, :external_url, :geozone_id, :association_name, + :administrator_id, :tag_list, valuator_ids: []) end def load_admins @@ -54,4 +58,4 @@ class Admin::SpendingProposalsController < Admin::BaseController @tags = ActsAsTaggableOn::Tag.spending_proposal_tags end -end \ No newline at end of file +end diff --git a/app/controllers/budgets/investments_controller.rb b/app/controllers/budgets/investments_controller.rb index 9ad48c1b7..16144cb27 100644 --- a/app/controllers/budgets/investments_controller.rb +++ b/app/controllers/budgets/investments_controller.rb @@ -28,7 +28,8 @@ module Budgets respond_to :html, :js def index - @investments = @investments.apply_filters_and_search(@budget, params, @current_filter).send("sort_by_#{@current_order}").page(params[:page]).per(10).for_render + @investments = @investments.apply_filters_and_search(@budget, params, @current_filter) + .send("sort_by_#{@current_order}").page(params[:page]).per(10).for_render @investment_ids = @investments.pluck(:id) load_investment_votes(@investments) @tag_cloud = tag_cloud @@ -102,7 +103,8 @@ module Budgets end def investment_params - params.require(:budget_investment).permit(:title, :description, :external_url, :heading_id, :tag_list, :organization_name, :location, :terms_of_service) + params.require(:budget_investment).permit(:title, :description, :external_url, :heading_id, :tag_list, + :organization_name, :location, :terms_of_service) end def load_ballot diff --git a/app/controllers/concerns/commentable_actions.rb b/app/controllers/concerns/commentable_actions.rb index 195d10459..62bcdaaac 100644 --- a/app/controllers/concerns/commentable_actions.rb +++ b/app/controllers/concerns/commentable_actions.rb @@ -88,7 +88,8 @@ module CommentableActions end def set_geozone - @resource.geozone = Geozone.find(params[resource_name.to_sym].try(:[], :geozone_id)) if params[resource_name.to_sym].try(:[], :geozone_id).present? + geozone_id = params[resource_name.to_sym].try(:[], :geozone_id) + @resource.geozone = Geozone.find(geozone_id) if geozone_id.present? end def load_categories @@ -109,4 +110,4 @@ module CommentableActions nil end -end \ No newline at end of file +end diff --git a/app/controllers/legislation/annotations_controller.rb b/app/controllers/legislation/annotations_controller.rb index fa46e5348..352fce266 100644 --- a/app/controllers/legislation/annotations_controller.rb +++ b/app/controllers/legislation/annotations_controller.rb @@ -102,8 +102,9 @@ class Legislation::AnnotationsController < ApplicationController end def convert_ranges_parameters - if params[:legislation_annotation] && params[:legislation_annotation][:ranges] && params[:legislation_annotation][:ranges].is_a?(String) - params[:legislation_annotation][:ranges] = JSON.parse(params[:legislation_annotation][:ranges]) + annotation = params[:legislation_annotation] + if annotation && annotation[:ranges] && annotation[:ranges].is_a?(String) + params[:legislation_annotation][:ranges] = JSON.parse(annotation[:ranges]) end rescue JSON::ParserError end diff --git a/app/controllers/legislation/answers_controller.rb b/app/controllers/legislation/answers_controller.rb index 36f87de1f..2e7e058e7 100644 --- a/app/controllers/legislation/answers_controller.rb +++ b/app/controllers/legislation/answers_controller.rb @@ -18,9 +18,10 @@ class Legislation::AnswersController < Legislation::BaseController format.html { redirect_to legislation_process_question_path(@process, @question) } end else + alert = t('legislation.questions.participation.phase_not_open') respond_to do |format| format.js { render json: {}, status: :not_found } - format.html { redirect_to legislation_process_question_path(@process, @question), alert: t('legislation.questions.participation.phase_not_open') } + format.html { redirect_to legislation_process_question_path(@process, @question), alert: alert } end end end diff --git a/app/controllers/management/document_verifications_controller.rb b/app/controllers/management/document_verifications_controller.rb index 510e4fa93..687d8ee52 100644 --- a/app/controllers/management/document_verifications_controller.rb +++ b/app/controllers/management/document_verifications_controller.rb @@ -43,7 +43,8 @@ class Management::DocumentVerificationsController < Management::BaseController end def clean_document_number - params[:document_verification][:document_number] = params[:document_verification][:document_number].gsub(/[^a-z0-9]+/i, "").upcase unless params[:document_verification][:document_number].blank? + return if params[:document_verification][:document_number].blank? + params[:document_verification][:document_number] = params[:document_verification][:document_number].gsub(/[^a-z0-9]+/i, "").upcase end -end \ No newline at end of file +end diff --git a/app/controllers/management/proposals_controller.rb b/app/controllers/management/proposals_controller.rb index 1a30526f5..54616c05b 100644 --- a/app/controllers/management/proposals_controller.rb +++ b/app/controllers/management/proposals_controller.rb @@ -34,7 +34,8 @@ class Management::ProposalsController < Management::BaseController end def proposal_params - params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url, :responsible_name, :tag_list, :terms_of_service, :geozone_id) + params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url, + :responsible_name, :tag_list, :terms_of_service, :geozone_id) end def resource_model @@ -53,4 +54,4 @@ class Management::ProposalsController < Management::BaseController @comment_flags = managed_user ? managed_user.comment_flags(comments) : {} end -end \ No newline at end of file +end diff --git a/app/controllers/management/spending_proposals_controller.rb b/app/controllers/management/spending_proposals_controller.rb index 6b2c4c0f1..f68c54f46 100644 --- a/app/controllers/management/spending_proposals_controller.rb +++ b/app/controllers/management/spending_proposals_controller.rb @@ -17,7 +17,8 @@ class Management::SpendingProposalsController < Management::BaseController @spending_proposal.author = managed_user if @spending_proposal.save - redirect_to management_spending_proposal_path(@spending_proposal), notice: t('flash.actions.create.notice', resource_name: t("activerecord.models.spending_proposal", count: 1)) + notice = t('flash.actions.create.notice', resource_name: t("activerecord.models.spending_proposal", count: 1)) + redirect_to management_spending_proposal_path(@spending_proposal), notice: notice else render :new end diff --git a/app/controllers/officing/final_recounts_controller.rb b/app/controllers/officing/final_recounts_controller.rb index 8be6e1a91..3efd6a682 100644 --- a/app/controllers/officing/final_recounts_controller.rb +++ b/app/controllers/officing/final_recounts_controller.rb @@ -15,7 +15,8 @@ class Officing::FinalRecountsController < Officing::BaseController end def create - @final_recount = ::Poll::FinalRecount.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id, date: final_recount_params[:date]) + @final_recount = ::Poll::FinalRecount.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id, + date: final_recount_params[:date]) @final_recount.officer_assignment_id = @officer_assignment.id @final_recount.count = final_recount_params[:count] @@ -45,4 +46,4 @@ class Officing::FinalRecountsController < Officing::BaseController params.permit(:officer_assignment_id, :count, :date) end -end \ No newline at end of file +end diff --git a/app/controllers/officing/recounts_controller.rb b/app/controllers/officing/recounts_controller.rb index 9e3989c05..b7ebf6acc 100644 --- a/app/controllers/officing/recounts_controller.rb +++ b/app/controllers/officing/recounts_controller.rb @@ -14,7 +14,8 @@ class Officing::RecountsController < Officing::BaseController end def create - @recount = ::Poll::Recount.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id, date: @officer_assignment.date) + @recount = ::Poll::Recount.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id, + date: @officer_assignment.date) @recount.officer_assignment_id = @officer_assignment.id @recount.count = recount_params[:count] @@ -44,4 +45,4 @@ class Officing::RecountsController < Officing::BaseController params.permit(:officer_assignment_id, :count) end -end \ No newline at end of file +end diff --git a/app/controllers/officing/results_controller.rb b/app/controllers/officing/results_controller.rb index b6377e25b..3a921a0d9 100644 --- a/app/controllers/officing/results_controller.rb +++ b/app/controllers/officing/results_controller.rb @@ -126,7 +126,8 @@ class Officing::ResultsController < Officing::BaseController def load_partial_results if @officer_assignments.present? - @partial_results = ::Poll::PartialResult.where(officer_assignment_id: @officer_assignments.map(&:id)).order(:booth_assignment_id, :date) + @partial_results = ::Poll::PartialResult.where(officer_assignment_id: @officer_assignments.map(&:id)) + .order(:booth_assignment_id, :date) end end diff --git a/app/controllers/organizations/registrations_controller.rb b/app/controllers/organizations/registrations_controller.rb index a77534d8c..0fd45e9f7 100644 --- a/app/controllers/organizations/registrations_controller.rb +++ b/app/controllers/organizations/registrations_controller.rb @@ -32,7 +32,8 @@ class Organizations::RegistrationsController < Devise::RegistrationsController private def sign_up_params - params.require(:user).permit(:email, :password, :phone_number, :password_confirmation, :terms_of_service, organization_attributes: [:name, :responsible_name]) + params.require(:user).permit(:email, :password, :phone_number, :password_confirmation, :terms_of_service, + organization_attributes: [:name, :responsible_name]) end end diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 0dab0fa9e..8b75a10cf 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -74,7 +74,8 @@ class ProposalsController < ApplicationController private def proposal_params - params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url, :responsible_name, :tag_list, :terms_of_service, :geozone_id) + params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url, + :responsible_name, :tag_list, :terms_of_service, :geozone_id) end def retired_params @@ -109,7 +110,8 @@ class ProposalsController < ApplicationController end def load_featured - @featured_proposals = Proposal.not_archived.sort_by_confidence_score.limit(3) if (!@advanced_search_terms && @search_terms.blank? && @tag_filter.blank? && params[:retired].blank?) + return unless !@advanced_search_terms && @search_terms.blank? && @tag_filter.blank? && params[:retired].blank? + @featured_proposals = Proposal.not_archived.sort_by_confidence_score.limit(3) if @featured_proposals.present? set_featured_proposal_votes(@featured_proposals) @resources = @resources.where('proposals.id NOT IN (?)', @featured_proposals.map(&:id)) diff --git a/app/controllers/spending_proposals_controller.rb b/app/controllers/spending_proposals_controller.rb index 5f8b04717..91ad8641c 100644 --- a/app/controllers/spending_proposals_controller.rb +++ b/app/controllers/spending_proposals_controller.rb @@ -30,7 +30,8 @@ class SpendingProposalsController < ApplicationController @spending_proposal.author = current_user if @spending_proposal.save - notice = t('flash.actions.create.spending_proposal', activity: "#{t('layouts.header.my_activity_link')}") + activity = "#{t('layouts.header.my_activity_link')}" + notice = t('flash.actions.create.spending_proposal', activity: activity) redirect_to @spending_proposal, notice: notice, flash: { html_safe: true } else render :new diff --git a/app/controllers/valuation/budget_investments_controller.rb b/app/controllers/valuation/budget_investments_controller.rb index c01f87c38..135a3e44c 100644 --- a/app/controllers/valuation/budget_investments_controller.rb +++ b/app/controllers/valuation/budget_investments_controller.rb @@ -12,11 +12,13 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController def index @heading_filters = heading_filters - if current_user.valuator? && @budget.present? - @investments = @budget.investments.scoped_filter(params_for_current_valuator, @current_filter).order(cached_votes_up: :desc).page(params[:page]) - else - @investments = Budget::Investment.none.page(params[:page]) - end + @investments = if current_user.valuator? && @budget.present? + @budget.investments.scoped_filter(params_for_current_valuator, @current_filter) + .order(cached_votes_up: :desc) + .page(params[:page]) + else + Budget::Investment.none.page(params[:page]) + end end def valuate @@ -63,11 +65,14 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController end def valuation_params - params.require(:budget_investment).permit(:price, :price_first_year, :price_explanation, :feasibility, :unfeasibility_explanation, :duration, :valuation_finished, :internal_comments) + params.require(:budget_investment).permit(:price, :price_first_year, :price_explanation, :feasibility, :unfeasibility_explanation, + :duration, :valuation_finished, :internal_comments) end def restrict_access_to_assigned_items - raise ActionController::RoutingError.new('Not Found') unless current_user.administrator? || Budget::ValuatorAssignment.exists?(investment_id: params[:id], valuator_id: current_user.valuator.id) + return if current_user.administrator? || + Budget::ValuatorAssignment.exists?(investment_id: params[:id], valuator_id: current_user.valuator.id) + raise ActionController::RoutingError.new('Not Found') end def valid_price_params? diff --git a/app/controllers/valuation/spending_proposals_controller.rb b/app/controllers/valuation/spending_proposals_controller.rb index 1273b80b6..53efcbc2e 100644 --- a/app/controllers/valuation/spending_proposals_controller.rb +++ b/app/controllers/valuation/spending_proposals_controller.rb @@ -10,11 +10,13 @@ class Valuation::SpendingProposalsController < Valuation::BaseController def index @geozone_filters = geozone_filters - if current_user.valuator? - @spending_proposals = SpendingProposal.scoped_filter(params_for_current_valuator, @current_filter).order(cached_votes_up: :desc).page(params[:page]) - else - @spending_proposals = SpendingProposal.none.page(params[:page]) - end + @spending_proposals = if current_user.valuator? + SpendingProposal.scoped_filter(params_for_current_valuator, @current_filter) + .order(cached_votes_up: :desc) + .page(params[:page]) + else + SpendingProposal.none.page(params[:page]) + end end def valuate @@ -54,7 +56,8 @@ class Valuation::SpendingProposalsController < Valuation::BaseController def valuation_params params[:spending_proposal][:feasible] = nil if params[:spending_proposal][:feasible] == 'nil' - params.require(:spending_proposal).permit(:price, :price_first_year, :price_explanation, :feasible, :feasible_explanation, :time_scope, :valuation_finished, :internal_comments) + params.require(:spending_proposal).permit(:price, :price_first_year, :price_explanation, :feasible, :feasible_explanation, + :time_scope, :valuation_finished, :internal_comments) end def params_for_current_valuator @@ -62,7 +65,9 @@ class Valuation::SpendingProposalsController < Valuation::BaseController end def restrict_access_to_assigned_items - raise ActionController::RoutingError.new('Not Found') unless current_user.administrator? || ValuationAssignment.exists?(spending_proposal_id: params[:id], valuator_id: current_user.valuator.id) + return if current_user.administrator? || + ValuationAssignment.exists?(spending_proposal_id: params[:id], valuator_id: current_user.valuator.id) + raise ActionController::RoutingError.new('Not Found') end def valid_price_params? @@ -77,4 +82,4 @@ class Valuation::SpendingProposalsController < Valuation::BaseController @spending_proposal.errors.empty? end -end \ No newline at end of file +end diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb index 3f760f73c..1936f843c 100644 --- a/app/helpers/comments_helper.rb +++ b/app/helpers/comments_helper.rb @@ -78,7 +78,9 @@ module CommentsHelper def require_verified_resident_for_commentable?(commentable, current_user) return false if current_user.administrator? || current_user.moderator? - commentable.respond_to?(:comments_for_verified_residents_only?) && commentable.comments_for_verified_residents_only? && !current_user.residence_verified? + commentable.respond_to?(:comments_for_verified_residents_only?) && + commentable.comments_for_verified_residents_only? && + !current_user.residence_verified? end def comments_closed_for_commentable?(commentable) diff --git a/app/helpers/valuation_helper.rb b/app/helpers/valuation_helper.rb index 4913b3d00..cc6a8e741 100644 --- a/app/helpers/valuation_helper.rb +++ b/app/helpers/valuation_helper.rb @@ -2,7 +2,9 @@ module ValuationHelper def valuator_select_options(valuator = nil) if valuator.present? - Valuator.where.not(id: valuator.id).order("description ASC").order("users.email ASC").includes(:user).collect { |v| [ v.description_or_email, v.id ] }.prepend([valuator.description_or_email, valuator.id]) + Valuator.where.not(id: valuator.id).order("description ASC").order("users.email ASC") + .includes(:user).collect { |v| [ v.description_or_email, v.id ] } + .prepend([valuator.description_or_email, valuator.id]) else Valuator.all.order("description ASC").order("users.email ASC").includes(:user).collect { |v| [ v.description_or_email, v.id ] } end @@ -27,4 +29,4 @@ module ValuationHelper simple_format_no_tags_no_sanitize(safe_html_with_links(field.html_safe)) if field.present? end -end \ No newline at end of file +end diff --git a/app/mailers/mailer.rb b/app/mailers/mailer.rb index fc2d926b4..32a8ebe4b 100644 --- a/app/mailers/mailer.rb +++ b/app/mailers/mailer.rb @@ -11,7 +11,8 @@ class Mailer < ApplicationMailer @email_to = @commentable.author.email with_user(@commentable.author) do - mail(to: @email_to, subject: t('mailers.comment.subject', commentable: t("activerecord.models.#{@commentable.class.name.underscore}", count: 1).downcase)) if @commentable.present? && @commentable.author.present? + subject = t('mailers.comment.subject', commentable: t("activerecord.models.#{@commentable.class.name.underscore}", count: 1).downcase) + mail(to: @email_to, subject: subject) if @commentable.present? && @commentable.author.present? end end diff --git a/app/models/abilities/administrator.rb b/app/models/abilities/administrator.rb index 2dd0d4031..bc2fea5d4 100644 --- a/app/models/abilities/administrator.rb +++ b/app/models/abilities/administrator.rb @@ -32,7 +32,8 @@ module Abilities can :mark_featured, Debate can :unmark_featured, Debate - can :comment_as_administrator, [Debate, Comment, Proposal, Poll::Question, Budget::Investment, Legislation::Question, Legislation::Annotation] + can :comment_as_administrator, [Debate, Comment, Proposal, Poll::Question, Budget::Investment, + Legislation::Question, Legislation::Annotation] can [:search, :create, :index, :destroy], ::Administrator can [:search, :create, :index, :destroy], ::Moderator diff --git a/app/models/abilities/moderator.rb b/app/models/abilities/moderator.rb index 479223b21..796bb185a 100644 --- a/app/models/abilities/moderator.rb +++ b/app/models/abilities/moderator.rb @@ -5,7 +5,8 @@ module Abilities def initialize(user) merge Abilities::Moderation.new(user) - can :comment_as_moderator, [Debate, Comment, Proposal, Budget::Investment, Poll::Question, Legislation::Question, Legislation::Annotation] + can :comment_as_moderator, [Debate, Comment, Proposal, Budget::Investment, Poll::Question, + Legislation::Question, Legislation::Annotation] end end end diff --git a/app/models/budget/ballot/line.rb b/app/models/budget/ballot/line.rb index 2b70953f1..a3c24b631 100644 --- a/app/models/budget/ballot/line.rb +++ b/app/models/budget/ballot/line.rb @@ -22,7 +22,8 @@ class Budget end def check_valid_heading - errors.add(:heading, "This heading's budget is invalid, or a heading on the same group was already selected") unless ballot.valid_heading?(heading) + return if ballot.valid_heading?(heading) + errors.add(:heading, "This heading's budget is invalid, or a heading on the same group was already selected") end def check_selected diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index 1cb3733a6..a5bea4508 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -205,7 +205,7 @@ class Budget end def recalculate_heading_winners - Budget::Result.new(budget, heading).calculate_winners if incompatible_changed? && winner? && incompatible? + Budget::Result.new(budget, heading).calculate_winners if incompatible_changed? end def set_responsible_name diff --git a/app/models/budget/result.rb b/app/models/budget/result.rb index aa6c4c7ac..d034e50ef 100644 --- a/app/models/budget/result.rb +++ b/app/models/budget/result.rb @@ -15,7 +15,6 @@ class Budget set_winner if inside_budget? end end - handle_asynchronously :calculate_winners def investments heading.investments.selected.sort_by_ballots diff --git a/app/models/comment.rb b/app/models/comment.rb index 44bb1f6f3..1db9809ee 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -3,6 +3,8 @@ class Comment < ActiveRecord::Base include HasPublicAuthor include Graphqlable + COMMENTABLE_TYPES = %w(Debate Proposal Budget::Investment Poll::Question Legislation::Question Legislation::Annotation).freeze + acts_as_paranoid column: :hidden_at include ActsAsParanoidAliases acts_as_votable @@ -13,7 +15,7 @@ class Comment < ActiveRecord::Base validates :body, presence: true validates :user, presence: true - validates :commentable_type, inclusion: { in: ["Debate", "Proposal", "Budget::Investment", "Poll::Question", "Legislation::Question", "Legislation::Annotation"] } + validates :commentable_type, inclusion: { in: COMMENTABLE_TYPES } validate :validate_body_length diff --git a/app/models/legislation/answer.rb b/app/models/legislation/answer.rb index cd415d0d4..7ee6119b5 100644 --- a/app/models/legislation/answer.rb +++ b/app/models/legislation/answer.rb @@ -2,8 +2,10 @@ class Legislation::Answer < ActiveRecord::Base acts_as_paranoid column: :hidden_at include ActsAsParanoidAliases - belongs_to :question, class_name: 'Legislation::Question', foreign_key: 'legislation_question_id', inverse_of: :answers, counter_cache: true - belongs_to :question_option, class_name: 'Legislation::QuestionOption', foreign_key: 'legislation_question_option_id', inverse_of: :answers, counter_cache: true + belongs_to :question, class_name: 'Legislation::Question', foreign_key: 'legislation_question_id', + inverse_of: :answers, counter_cache: true + belongs_to :question_option, class_name: 'Legislation::QuestionOption', foreign_key: 'legislation_question_option_id', + inverse_of: :answers, counter_cache: true belongs_to :user, dependent: :destroy, inverse_of: :legislation_answers validates :question, presence: true, uniqueness: { scope: :user_id} diff --git a/app/models/legislation/process.rb b/app/models/legislation/process.rb index 59ab99433..b6043df57 100644 --- a/app/models/legislation/process.rb +++ b/app/models/legislation/process.rb @@ -4,8 +4,10 @@ class Legislation::Process < ActiveRecord::Base PHASES_AND_PUBLICATIONS = %i(debate_phase allegations_phase draft_publication result_publication).freeze - has_many :draft_versions, -> { order(:id) }, class_name: 'Legislation::DraftVersion', foreign_key: 'legislation_process_id', dependent: :destroy - has_one :final_draft_version, -> { where final_version: true, status: 'published' }, class_name: 'Legislation::DraftVersion', foreign_key: 'legislation_process_id' + has_many :draft_versions, -> { order(:id) }, class_name: 'Legislation::DraftVersion', + foreign_key: 'legislation_process_id', dependent: :destroy + has_one :final_draft_version, -> { where final_version: true, status: 'published' }, class_name: 'Legislation::DraftVersion', + foreign_key: 'legislation_process_id' has_many :questions, -> { order(:id) }, class_name: 'Legislation::Question', foreign_key: 'legislation_process_id', dependent: :destroy validates :title, presence: true @@ -64,7 +66,9 @@ class Legislation::Process < ActiveRecord::Base def valid_date_ranges errors.add(:end_date, :invalid_date_range) if end_date && start_date && end_date < start_date errors.add(:debate_end_date, :invalid_date_range) if debate_end_date && debate_start_date && debate_end_date < debate_start_date - errors.add(:allegations_end_date, :invalid_date_range) if allegations_end_date && allegations_start_date && allegations_end_date < allegations_start_date + if allegations_end_date && allegations_start_date && allegations_end_date < allegations_start_date + errors.add(:allegations_end_date, :invalid_date_range) + end end end diff --git a/app/models/legislation/question.rb b/app/models/legislation/question.rb index 09449b449..71ce100ea 100644 --- a/app/models/legislation/question.rb +++ b/app/models/legislation/question.rb @@ -5,7 +5,8 @@ class Legislation::Question < ActiveRecord::Base belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id' belongs_to :process, class_name: 'Legislation::Process', foreign_key: 'legislation_process_id' - has_many :question_options, -> { order(:id) }, class_name: 'Legislation::QuestionOption', foreign_key: 'legislation_question_id', dependent: :destroy, inverse_of: :question + has_many :question_options, -> { order(:id) }, class_name: 'Legislation::QuestionOption', foreign_key: 'legislation_question_id', + dependent: :destroy, inverse_of: :question has_many :answers, class_name: 'Legislation::Answer', foreign_key: 'legislation_question_id', dependent: :destroy, inverse_of: :question has_many :comments, as: :commentable, dependent: :destroy diff --git a/app/models/organization.rb b/app/models/organization.rb index 37b46df55..e5b568818 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -35,7 +35,11 @@ class Organization < ActiveRecord::Base end def self.search(text) - text.present? ? joins(:user).where("users.email = ? OR users.phone_number = ? OR organizations.name ILIKE ?", text, text, "%#{text}%") : none + if text.present? + joins(:user).where("users.email = ? OR users.phone_number = ? OR organizations.name ILIKE ?", text, text, "%#{text}%") + else + none + end end def self.name_max_length diff --git a/app/models/proposal_notification.rb b/app/models/proposal_notification.rb index 9f36679a4..bd4211a85 100644 --- a/app/models/proposal_notification.rb +++ b/app/models/proposal_notification.rb @@ -14,8 +14,10 @@ class ProposalNotification < ActiveRecord::Base def minimum_interval return true if proposal.try(:notifications).blank? - if proposal.notifications.last.created_at > (Time.current - Setting[:proposal_notification_minimum_interval_in_days].to_i.days).to_datetime - errors.add(:title, I18n.t('activerecord.errors.models.proposal_notification.attributes.minimum_interval.invalid', interval: Setting[:proposal_notification_minimum_interval_in_days])) + interval = Setting[:proposal_notification_minimum_interval_in_days] + minimum_interval = (Time.current - interval.to_i.days).to_datetime + if proposal.notifications.last.created_at > minimum_interval + errors.add(:title, I18n.t('activerecord.errors.models.proposal_notification.attributes.minimum_interval.invalid', interval: interval)) end end diff --git a/app/models/verification/residence.rb b/app/models/verification/residence.rb index c14bba85d..9eaf89555 100644 --- a/app/models/verification/residence.rb +++ b/app/models/verification/residence.rb @@ -38,8 +38,8 @@ class Verification::Residence end def allowed_age - return if errors[:date_of_birth].any? - errors.add(:date_of_birth, I18n.t('verification.residence.new.error_not_allowed_age')) unless Age.in_years(date_of_birth) >= User.minimum_required_age + return if errors[:date_of_birth].any? || Age.in_years(date_of_birth) >= User.minimum_required_age + errors.add(:date_of_birth, I18n.t('verification.residence.new.error_not_allowed_age')) end def document_number_uniqueness diff --git a/app/views/admin/budget_investments/edit.html.erb b/app/views/admin/budget_investments/edit.html.erb index 1e21ee706..c33039021 100644 --- a/app/views/admin/budget_investments/edit.html.erb +++ b/app/views/admin/budget_investments/edit.html.erb @@ -63,6 +63,7 @@
<%= milestone.description %>