From 35e8e9da3141149307f8fd7e69911a60925abc58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sun, 20 Oct 2019 17:16:26 +0200 Subject: [PATCH 1/8] Fix validations being accidentally skipped in spec We were trying to test a before_validation call, but the `touch` method skips validations. --- spec/models/budget/investment_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/budget/investment_spec.rb b/spec/models/budget/investment_spec.rb index 4f87927d0..ae896819c 100644 --- a/spec/models/budget/investment_spec.rb +++ b/spec/models/budget/investment_spec.rb @@ -989,7 +989,7 @@ describe Budget::Investment do user.erase user.update!(document_number: nil) expect(user.document_number).to be_blank - investment.touch + investment.valid? expect(investment.responsible_name).to eq("123456") end end From bbce3479cff60757dc38cbb738122e1f81547a6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 23 Oct 2019 02:56:28 +0200 Subject: [PATCH 2/8] Simplify touching a budget when a phase changes The `belongs_to` method already has that option, so there's no need to do it manually in an `after_save` callback. --- app/models/budget/phase.rb | 7 +------ spec/models/budget/phase_spec.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/models/budget/phase.rb b/app/models/budget/phase.rb index 6432a13b1..de90075a7 100644 --- a/app/models/budget/phase.rb +++ b/app/models/budget/phase.rb @@ -11,7 +11,7 @@ class Budget include Globalizable include Sanitizable - belongs_to :budget + belongs_to :budget, touch: true belongs_to :next_phase, class_name: self.name, inverse_of: :prev_phase has_one :prev_phase, class_name: self.name, foreign_key: :next_phase_id, inverse_of: :next_phase @@ -24,7 +24,6 @@ class Budget validate :next_phase_dates_valid? after_save :adjust_date_ranges - after_save :touch_budget scope :enabled, -> { where(enabled: true) } scope :published, -> { enabled.where.not(kind: "drafting") } @@ -70,10 +69,6 @@ class Budget end end - def touch_budget - budget.touch - end - def prev_phase_dates_valid? if enabled? && starts_at.present? && prev_enabled_phase.present? prev_enabled_phase.assign_attributes(ends_at: starts_at) diff --git a/spec/models/budget/phase_spec.rb b/spec/models/budget/phase_spec.rb index c0b4852b7..e44a2e234 100644 --- a/spec/models/budget/phase_spec.rb +++ b/spec/models/budget/phase_spec.rb @@ -115,6 +115,18 @@ describe Budget::Phase do end end + describe "#save" do + it "touches the budget when it's updated" do + budget = create(:budget) + + travel(10.seconds) do + budget.current_phase.update!(enabled: false) + + expect(budget.updated_at).to eq Time.current + end + end + end + describe "#adjust_date_ranges" do let(:prev_enabled_phase) { second_phase.prev_enabled_phase } let(:next_enabled_phase) { second_phase.next_enabled_phase } From 97e826f2a4434e62b9f172bfded8bbf00e7f5e4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sun, 20 Oct 2019 16:29:46 +0200 Subject: [PATCH 3/8] Don't use `update_attribute` This method is ambiguous. Sometimes we use it to set invalid data in tests (which can usually be done with `update_column`), and other times we use it instead of `update!`. I'm removing it because, even if sometimes it could make sense to use it, it's too similar to `update_attributes` (which is an alias for `update` and runs validations), making it confusing. However, there's one case where we're still using it: in the ActsAsParanoidAliases module, we need to invoke the callbacks, which `update_column` skips, but tests related to translations fail if we use `update!`. The reason for this is the tests check what happens if we restore a record without restoring its translations. But that will make the record invalid, since there's a validation rule checking it has at least one translation. I'm not blacklisting any other method which skips validations because we know they skip validations and use them anyway (hopefully with care). --- .rubocop.yml | 3 --- .rubocop_basic.yml | 6 ++++++ app/controllers/debates_controller.rb | 4 ++-- app/models/poll/question/answer.rb | 2 +- spec/controllers/comments_controller_spec.rb | 2 +- spec/controllers/legislation/annotations_controller_spec.rb | 2 +- spec/controllers/legislation/answers_controller_spec.rb | 2 +- spec/features/admin/admin_notifications_spec.rb | 6 +++--- spec/features/admin/budget_investments_spec.rb | 2 +- spec/features/admin/emails/emails_download_spec.rb | 2 +- spec/features/admin/emails/newsletters_spec.rb | 6 +++--- spec/features/legislation/questions_spec.rb | 2 +- spec/lib/email_digests_spec.rb | 2 +- spec/models/concerns/globalizable.rb | 6 +++--- spec/models/proposal_spec.rb | 2 +- 15 files changed, 26 insertions(+), 23 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 1f4d68f62..4928a817d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -18,9 +18,6 @@ Performance/StartWith: Rails/HasManyOrHasOneDependent: Enabled: true -Rails/SkipsModelValidations: - Enabled: true - Security/JSONLoad: Enabled: true diff --git a/.rubocop_basic.yml b/.rubocop_basic.yml index 364ae1b84..6ae2b10af 100644 --- a/.rubocop_basic.yml +++ b/.rubocop_basic.yml @@ -248,6 +248,12 @@ Rails/SaveBang: Enabled: true Severity: refactor +Rails/SkipsModelValidations: + Enabled: true + Blacklist: + - update_attribute + Exclude: lib/acts_as_paranoid_aliases.rb + Rails/TimeZone: Enabled: true diff --git a/app/controllers/debates_controller.rb b/app/controllers/debates_controller.rb index 67ff502d4..ee2103ee2 100644 --- a/app/controllers/debates_controller.rb +++ b/app/controllers/debates_controller.rb @@ -36,12 +36,12 @@ class DebatesController < ApplicationController end def unmark_featured - @debate.update_attribute(:featured_at, nil) + @debate.update!(featured_at: nil) redirect_to request.query_parameters.merge(action: :index) end def mark_featured - @debate.update_attribute(:featured_at, Time.current) + @debate.update!(featured_at: Time.current) redirect_to request.query_parameters.merge(action: :index) end diff --git a/app/models/poll/question/answer.rb b/app/models/poll/question/answer.rb index cb431b9b2..91320743c 100644 --- a/app/models/poll/question/answer.rb +++ b/app/models/poll/question/answer.rb @@ -21,7 +21,7 @@ class Poll::Question::Answer < ApplicationRecord def self.order_answers(ordered_array) ordered_array.each_with_index do |answer_id, order| - find(answer_id).update_attribute(:given_order, (order + 1)) + find(answer_id).update_column(:given_order, (order + 1)) end end diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index 9ec1af021..6f9cfc9b2 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -27,7 +27,7 @@ describe CommentsController do it "does not create a comment if the comments are closed" do sign_in user - legal_process.update_attribute(:debate_end_date, Date.current - 1.day) + legal_process.update!(debate_end_date: Date.current - 1.day) expect do post :create, xhr: true, diff --git a/spec/controllers/legislation/annotations_controller_spec.rb b/spec/controllers/legislation/annotations_controller_spec.rb index b309d7910..1768b4a3d 100644 --- a/spec/controllers/legislation/annotations_controller_spec.rb +++ b/spec/controllers/legislation/annotations_controller_spec.rb @@ -81,7 +81,7 @@ describe Legislation::AnnotationsController do it "does not create an annotation if the process allegations phase is not open" do sign_in user - legal_process.update_attribute(:allegations_end_date, Date.current - 1.day) + legal_process.update!(allegations_end_date: Date.current - 1.day) expect do post :create, xhr: true, diff --git a/spec/controllers/legislation/answers_controller_spec.rb b/spec/controllers/legislation/answers_controller_spec.rb index b45b97e6f..e05731801 100644 --- a/spec/controllers/legislation/answers_controller_spec.rb +++ b/spec/controllers/legislation/answers_controller_spec.rb @@ -41,7 +41,7 @@ describe Legislation::AnswersController do it "does not create an answer if the process debate phase is not open" do sign_in user - legal_process.update_attribute(:debate_end_date, Date.current - 1.day) + legal_process.update!(debate_end_date: Date.current - 1.day) expect do post :create, xhr: true, diff --git a/spec/features/admin/admin_notifications_spec.rb b/spec/features/admin/admin_notifications_spec.rb index 1829e2d60..6e8f69c9e 100644 --- a/spec/features/admin/admin_notifications_spec.rb +++ b/spec/features/admin/admin_notifications_spec.rb @@ -23,7 +23,7 @@ describe "Admin Notifications" do scenario "Notification with invalid segment recipient" do invalid_notification = create(:admin_notification) - invalid_notification.update_attribute(:segment_recipient, "invalid_segment") + invalid_notification.update_column(:segment_recipient, "invalid_segment") visit admin_admin_notification_path(invalid_notification) @@ -56,7 +56,7 @@ describe "Admin Notifications" do scenario "Notifications with invalid segment recipient" do invalid_notification = create(:admin_notification) - invalid_notification.update_attribute(:segment_recipient, "invalid_segment") + invalid_notification.update_column(:segment_recipient, "invalid_segment") visit admin_admin_notifications_path @@ -209,7 +209,7 @@ describe "Admin Notifications" do scenario "Admin notification with invalid segment recipient cannot be sent", :js do invalid_notification = create(:admin_notification) - invalid_notification.update_attribute(:segment_recipient, "invalid_segment") + invalid_notification.update_column(:segment_recipient, "invalid_segment") visit admin_admin_notification_path(invalid_notification) expect(page).not_to have_link("Send") diff --git a/spec/features/admin/budget_investments_spec.rb b/spec/features/admin/budget_investments_spec.rb index 93d55e92a..3bb12abdb 100644 --- a/spec/features/admin/budget_investments_spec.rb +++ b/spec/features/admin/budget_investments_spec.rb @@ -1832,7 +1832,7 @@ describe "Admin budget investments" do end scenario "Select an investment when some columns are not displayed", :js do - investment.update_attribute(:title, "Don't display me, please!") + investment.update!(title: "Don't display me, please!") visit admin_budget_budget_investments_path(budget) within("#js-columns-selector") { find("strong", text: "Columns").click } diff --git a/spec/features/admin/emails/emails_download_spec.rb b/spec/features/admin/emails/emails_download_spec.rb index 382107199..9c29a0742 100644 --- a/spec/features/admin/emails/emails_download_spec.rb +++ b/spec/features/admin/emails/emails_download_spec.rb @@ -19,7 +19,7 @@ describe "Admin download user emails" do admin_without_email = create(:user, newsletter: true, email: "no_email@consul.dev") create(:administrator, user: admin_without_email) - admin_without_email.update_attribute(:email, nil) + admin_without_email.update_column(:email, nil) end scenario "returns the selected users segment csv file" do diff --git a/spec/features/admin/emails/newsletters_spec.rb b/spec/features/admin/emails/newsletters_spec.rb index a1acb8ef4..d78b3c0fe 100644 --- a/spec/features/admin/emails/newsletters_spec.rb +++ b/spec/features/admin/emails/newsletters_spec.rb @@ -23,7 +23,7 @@ describe "Admin newsletter emails" do scenario "Invalid newsletter" do invalid_newsletter = create(:newsletter) - invalid_newsletter.update_attribute(:segment_recipient, "invalid_segment") + invalid_newsletter.update_column(:segment_recipient, "invalid_segment") visit admin_newsletter_path(invalid_newsletter) @@ -50,7 +50,7 @@ describe "Admin newsletter emails" do scenario "Invalid newsletter" do invalid_newsletter = create(:newsletter) - invalid_newsletter.update_attribute(:segment_recipient, "invalid_segment") + invalid_newsletter.update_column(:segment_recipient, "invalid_segment") visit admin_newsletters_path @@ -136,7 +136,7 @@ describe "Admin newsletter emails" do scenario "Invalid newsletter cannot be sent", :js do invalid_newsletter = create(:newsletter) - invalid_newsletter.update_attribute(:segment_recipient, "invalid_segment") + invalid_newsletter.update_column(:segment_recipient, "invalid_segment") visit admin_newsletter_path(invalid_newsletter) expect(page).not_to have_link("Send") diff --git a/spec/features/legislation/questions_spec.rb b/spec/features/legislation/questions_spec.rb index 32d416c77..10deb9a95 100644 --- a/spec/features/legislation/questions_spec.rb +++ b/spec/features/legislation/questions_spec.rb @@ -94,7 +94,7 @@ describe "Legislation" do end scenario "cannot answer question when phase not open" do - process.update_attribute(:debate_end_date, Date.current - 1.day) + process.update!(debate_end_date: Date.current - 1.day) question = process.questions.first create(:legislation_question_option, question: question, value: "Yes") create(:legislation_question_option, question: question, value: "No") diff --git a/spec/lib/email_digests_spec.rb b/spec/lib/email_digests_spec.rb index ab96fc0d6..d079691c9 100644 --- a/spec/lib/email_digests_spec.rb +++ b/spec/lib/email_digests_spec.rb @@ -133,7 +133,7 @@ describe EmailDigest do it "returns false if email does not exist" do user = create(:user) - user.update_attribute(:email, nil) + user.email = nil email_digest = EmailDigest.new(user) expect(email_digest.valid_email?).to be(false) diff --git a/spec/models/concerns/globalizable.rb b/spec/models/concerns/globalizable.rb index fc4c01e61..c72de6499 100644 --- a/spec/models/concerns/globalizable.rb +++ b/spec/models/concerns/globalizable.rb @@ -13,11 +13,11 @@ shared_examples_for "globalizable" do |factory_name| let(:attribute) { required_fields.sample || fields.sample } before do - record.update_attribute(attribute, "In English") + record.update!(attribute => "In English") I18n.with_locale(:es) do record.update!(required_fields.map { |field| [field, "En español"] }.to_h) - record.update_attribute(attribute, "En español") + record.update!(attribute => "En español") end record.reload @@ -156,7 +156,7 @@ shared_examples_for "globalizable" do |factory_name| before do I18n.with_locale(:de) do record.update!(required_fields.map { |field| [field, "Deutsch"] }.to_h) - record.update_attribute(attribute, "Deutsch") + record.update!(attribute => "Deutsch") end end diff --git a/spec/models/proposal_spec.rb b/spec/models/proposal_spec.rb index e75660a53..3cc07c438 100644 --- a/spec/models/proposal_spec.rb +++ b/spec/models/proposal_spec.rb @@ -253,7 +253,7 @@ describe Proposal do proposal = create(:proposal) tag_list = ["tag1", "tag2", "tag3", "tag4", "tag5", "tag6", "tag7"] - proposal.update_attribute(:tag_list, tag_list) + proposal.update!(tag_list: tag_list) expect(proposal.update_cached_votes).to eq(true) end From f3c31f0ea3c704dcec42073c81d6a0d695e48557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 25 Oct 2019 03:31:49 +0200 Subject: [PATCH 4/8] Remove MarshalLoad rubocop rule We don't use Marshal objects in our application. --- .rubocop.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 4928a817d..10cd15e9a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -21,8 +21,5 @@ Rails/HasManyOrHasOneDependent: Security/JSONLoad: Enabled: true -Security/MarshalLoad: - Enabled: true - Security/YAMLLoad: Enabled: true From c06186a11193fa7b6d9d1c4467dd18e8a67e200e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 25 Oct 2019 03:26:38 +0200 Subject: [PATCH 5/8] Move performance and security rules to basic cops As mentioned in commit 9d566a22, I've kept these performance cops but not for performance reasons but because they make the code easier to read. As for the security cops, we've never had problems with any of them, but since we recently added an `eval` call by accident, there's a chance we could do the same with JSONLoad and YAMLLoad. --- .rubocop.yml | 22 ---------------------- .rubocop_basic.yml | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 10cd15e9a..59bdce84d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,25 +1,3 @@ inherit_from: .rubocop_basic.yml - -Performance/CompareWithBlock: - Enabled: true - -Performance/Detect: - Enabled: true - -Performance/DoubleStartEndWith: - Enabled: true - -Performance/EndWith: - Enabled: true - -Performance/StartWith: - Enabled: true - Rails/HasManyOrHasOneDependent: Enabled: true - -Security/JSONLoad: - Enabled: true - -Security/YAMLLoad: - Enabled: true diff --git a/.rubocop_basic.yml b/.rubocop_basic.yml index 6ae2b10af..4e85f36ec 100644 --- a/.rubocop_basic.yml +++ b/.rubocop_basic.yml @@ -170,6 +170,21 @@ Metrics/LineLength: Max: 110 Severity: refactor +Performance/CompareWithBlock: + Enabled: true + +Performance/Detect: + Enabled: true + +Performance/DoubleStartEndWith: + Enabled: true + +Performance/EndWith: + Enabled: true + +Performance/StartWith: + Enabled: true + Rails/ActionFilter: Enabled: true @@ -331,6 +346,12 @@ RSpec/VoidExpect: Security/Eval: Enabled: true +Security/JSONLoad: + Enabled: true + +Security/YAMLLoad: + Enabled: true + Style/BlockDelimiters: Enabled: true From dd0dbee73b9f0951c112f6082a8e50bbf8612989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 25 Oct 2019 03:41:00 +0200 Subject: [PATCH 6/8] Reduce severity of HasManyOrHasOneDependent rule This is actually a hack. We want Hound to warn us about this rule; however, we don't want to be notified about our many existing offenses. Ideally we would add the `dependent` option to all existing models. However, this is extra tricky because adding this option would change existing behavior. --- .rubocop.yml | 2 -- .rubocop_basic.yml | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 59bdce84d..e05f29bf6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1 @@ inherit_from: .rubocop_basic.yml -Rails/HasManyOrHasOneDependent: - Enabled: true diff --git a/.rubocop_basic.yml b/.rubocop_basic.yml index 4e85f36ec..27332462f 100644 --- a/.rubocop_basic.yml +++ b/.rubocop_basic.yml @@ -218,6 +218,10 @@ Rails/FindBy: Rails/FindEach: Enabled: true +Rails/HasManyOrHasOneDependent: + Enabled: true + Severity: refactor + Rails/HttpPositionalArguments: Enabled: true From 621523cfd988f7bd5fa0072763fd1f08d3b79381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 25 Oct 2019 03:41:49 +0200 Subject: [PATCH 7/8] Merge basic and standard rubocop files in one file A bit of history in order to understand this change. A year ago we introduced Hound so it would review our pull requests and warn contributors when they weren't following our coding style. However, back then we had many rules we hadn't reviewed yet, and we weren't sure we wanted to ask contributors to follow them. So we decided to split these files: .rubocop_basic.yml would contain rules we had already agreed on and wanted contributors to respect, and .rubocop.yml would contain rules we still had to review. Now we've finally gone through all these rules. We've removed some of them, kept some of them, added new ones, and applied them. Now all rules with a severity level of "convention" or higher return no offenses. The rules with "severity: refactor" return some offenses, though: * Metrics/LineLenght can only be properly accomplished when we define better multi-line indentation standards, while in some cases long lines indicate we need to refactor the code * Rails/DynamicFindBy returns a few false positives * Rails/HasManyOrHasOneDependent should by all means be implemented, although it will not be a trivial task * Rails/SaveBang returns a few false positives and there are a couple of places where we skip it on purpose There are also rules excluding some files: * Rails/InverseOf returns a false positive * Rails/OutputSafety is ignored on purpose when we add auto-links to a text we trust * RSpec/InstanceVariable returns false positives in two files Other than that, everything works as expected. --- .hound.yml | 2 +- .rubocop.yml | 369 ++++++++++++++++++++++++++++++++++++++++++++- .rubocop_basic.yml | 369 --------------------------------------------- 3 files changed, 369 insertions(+), 371 deletions(-) delete mode 100644 .rubocop_basic.yml diff --git a/.hound.yml b/.hound.yml index a8568704c..70fe6df63 100644 --- a/.hound.yml +++ b/.hound.yml @@ -1,5 +1,5 @@ rubocop: - config_file: .rubocop_basic.yml + config_file: .rubocop.yml version: 0.72.0 scss: config_file: .scss-lint.yml diff --git a/.rubocop.yml b/.rubocop.yml index e05f29bf6..d89574c31 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1 +1,368 @@ -inherit_from: .rubocop_basic.yml +require: + - rubocop-performance + - rubocop-rails + - rubocop-rspec + +AllCops: + DisplayCopNames: true + DisplayStyleGuide: true + Exclude: + - "db/schema.rb" + DisabledByDefault: true + +Bundler/DuplicatedGem: + Enabled: true + +Bundler/OrderedGems: + Enabled: true + +Capybara/CurrentPathExpectation: + Enabled: true + +Capybara/FeatureMethods: + Enabled: true + EnabledMethods: + - scenario + - xscenario + +FactoryBot/AttributeDefinedStatically: + Enabled: true + +Layout/EmptyLineAfterGuardClause: + Enabled: true + +Layout/EmptyLineBetweenDefs: + Enabled: true + +Layout/EmptyLines: + Enabled: true + +Layout/EmptyLinesAroundAccessModifier: + Enabled: true + +Layout/EmptyLinesAroundBlockBody: + Enabled: true + +Layout/EmptyLinesAroundClassBody: + Enabled: true + +Layout/EmptyLinesAroundMethodBody: + Enabled: true + +Layout/EmptyLinesAroundModuleBody: + Enabled: true + +Layout/EndOfLine: + EnforcedStyle: lf + +Layout/ExtraSpacing: + Enabled: true + +Layout/IndentationConsistency: + EnforcedStyle: indented_internal_methods + +Layout/IndentationWidth: + Enabled: true + +Layout/MultilineBlockLayout: + Enabled: true + +Layout/SpaceAfterColon: + Enabled: true + +Layout/SpaceAfterComma: + Enabled: true + +Layout/SpaceAfterMethodName: + Enabled: true + +Layout/SpaceAfterNot: + Enabled: true + +Layout/SpaceAfterSemicolon: + Enabled: true + +Layout/SpaceAroundBlockParameters: + Enabled: true + +Layout/SpaceAroundEqualsInParameterDefault: + Enabled: true + +Layout/SpaceAroundOperators: + Enabled: true + +Layout/SpaceBeforeBlockBraces: + Enabled: true + +Layout/SpaceBeforeComma: + Enabled: true + +Layout/SpaceBeforeComment: + Enabled: true + +Layout/SpaceBeforeFirstArg: + Enabled: true + +Layout/SpaceBeforeSemicolon: + Enabled: true + +Layout/SpaceInsideArrayLiteralBrackets: + Enabled: true + +Layout/SpaceInsideArrayPercentLiteral: + Enabled: true + +Layout/SpaceInsideBlockBraces: + Enabled: true + +Layout/SpaceInsideHashLiteralBraces: + Enabled: true + EnforcedStyle: compact + +Layout/SpaceInsideParens: + Enabled: true + +Layout/SpaceInsidePercentLiteralDelimiters: + Enabled: true + +Layout/SpaceInsideRangeLiteral: + Enabled: true + +Layout/SpaceInsideReferenceBrackets: + Enabled: true + +Layout/SpaceInsideStringInterpolation: + Enabled: true + +Layout/Tab: + Enabled: true + +Layout/TrailingBlankLines: + Enabled: true + +Layout/TrailingWhitespace: + Enabled: true + +Lint/AmbiguousRegexpLiteral: + Enabled: true + +Lint/DuplicateMethods: + Enabled: true + +Lint/LiteralAsCondition: + Enabled: true + +Lint/ParenthesesAsGroupedExpression: + Enabled: true + +Lint/ShadowingOuterLocalVariable: + Enabled: true + +Lint/StringConversionInInterpolation: + Enabled: true + +Lint/UselessAssignment: + Enabled: true + +Metrics/LineLength: + Max: 110 + Severity: refactor + +Performance/CompareWithBlock: + Enabled: true + +Performance/Detect: + Enabled: true + +Performance/DoubleStartEndWith: + Enabled: true + +Performance/EndWith: + Enabled: true + +Performance/StartWith: + Enabled: true + +Rails/ActionFilter: + Enabled: true + +Rails/ApplicationJob: + Enabled: true + +Rails/ApplicationRecord: + Enabled: true + +Rails/CreateTableWithTimestamps: + Enabled: true + Exclude: + - "db/migrate/201[5-8]*" + +Rails/Date: + Enabled: true + +Rails/DynamicFindBy: + Enabled: true + Severity: refactor + +Rails/EnumUniqueness: + Enabled: true + +Rails/EnvironmentComparison: + Enabled: true + +Rails/FindBy: + Enabled: true + +Rails/FindEach: + Enabled: true + +Rails/HasAndBelongsToMany: + Enabled: true + +Rails/HasManyOrHasOneDependent: + Enabled: true + Severity: refactor + +Rails/HttpPositionalArguments: + Enabled: true + +Rails/InverseOf: + Enabled: true + Exclude: + - "app/models/related_content.rb" + +Rails/NotNullColumn: + Enabled: true + Exclude: + - "db/migrate/201[5-7]*" + +Rails/OutputSafety: + Enabled: true + Severity: warning + Exclude: + - app/helpers/text_with_links_helper.rb + +Rails/PluralizationGrammar: + Enabled: true + +Rails/Presence: + Enabled: true + +Rails/RelativeDateConstant: + Enabled: true + +Rails/RequestReferer: + Enabled: true + +Rails/ReversibleMigration: + Enabled: true + +Rails/SafeNavigation: + Enabled: true + ConvertTry: true + +Rails/SaveBang: + Enabled: true + Severity: refactor + +Rails/SkipsModelValidations: + Enabled: true + Blacklist: + - update_attribute + Exclude: + - lib/acts_as_paranoid_aliases.rb + +Rails/TimeZone: + Enabled: true + +Rails/UnknownEnv: + Enabled: true + Environments: + - development + - test + - production + - preproduction + - staging + +Rails/Validation: + Enabled: true + +RSpec/AroundBlock: + Enabled: true + +RSpec/BeforeAfterAll: + Enabled: true + +RSpec/DescribedClass: + Enabled: true + EnforcedStyle: explicit + +RSpec/EmptyExampleGroup: + Enabled: true + Exclude: + - spec/factories/**/* + +RSpec/EmptyLineAfterExampleGroup: + Enabled: true + Exclude: + - spec/factories/**/* + +RSpec/ExampleWording: + Enabled: true + +RSpec/Focus: + Enabled: true + +RSpec/HookArgument: + Enabled: true + +RSpec/InstanceVariable: + Enabled: true + Exclude: + - spec/controllers/concerns/has_filters_spec.rb + - spec/controllers/concerns/has_orders_spec.rb + +RSpec/LetBeforeExamples: + Enabled: true + +RSpec/LetSetup: + Enabled: true + +RSpec/NotToNot: + Enabled: true + +RSpec/OverwritingSetup: + Enabled: true + +RSpec/RepeatedExample: + Enabled: true + +RSpec/ScatteredLet: + Enabled: true + +RSpec/ScatteredSetup: + Enabled: true + +RSpec/VoidExpect: + Enabled: true + +Security/Eval: + Enabled: true + +Security/JSONLoad: + Enabled: true + +Security/YAMLLoad: + Enabled: true + +Style/BlockDelimiters: + Enabled: true + +Style/PercentLiteralDelimiters: + Enabled: true + +Style/SafeNavigation: + Enabled: true + +Style/StringLiterals: + EnforcedStyle: double_quotes diff --git a/.rubocop_basic.yml b/.rubocop_basic.yml deleted file mode 100644 index 27332462f..000000000 --- a/.rubocop_basic.yml +++ /dev/null @@ -1,369 +0,0 @@ -require: - - rubocop-performance - - rubocop-rails - - rubocop-rspec - -AllCops: - DisplayCopNames: true - DisplayStyleGuide: true - Exclude: - - "db/schema.rb" - # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop - # to ignore them, so only the ones explicitly set in this file are enabled. - DisabledByDefault: true - -Bundler/DuplicatedGem: - Enabled: true - -Bundler/OrderedGems: - Enabled: true - -Capybara/CurrentPathExpectation: - Enabled: true - -Capybara/FeatureMethods: - Enabled: true - EnabledMethods: - - scenario - - xscenario - -FactoryBot/AttributeDefinedStatically: - Enabled: true - -Layout/EmptyLineAfterGuardClause: - Enabled: true - -Layout/EmptyLineBetweenDefs: - Enabled: true - -Layout/EmptyLinesAroundAccessModifier: - Enabled: true - -Layout/EmptyLinesAroundBlockBody: - Enabled: true - -Layout/EmptyLinesAroundClassBody: - Enabled: true - -Layout/EmptyLinesAroundMethodBody: - Enabled: true - -Layout/EmptyLinesAroundModuleBody: - Enabled: true - -Layout/ExtraSpacing: - Enabled: true - -Layout/SpaceAroundEqualsInParameterDefault: - Enabled: true - -Layout/IndentationConsistency: - EnforcedStyle: indented_internal_methods - -Layout/IndentationWidth: - Enabled: true - -Layout/EmptyLines: - Enabled: true - -Layout/EndOfLine: - EnforcedStyle: lf - -Layout/MultilineBlockLayout: - Enabled: true - -Layout/SpaceAfterColon: - Enabled: true - -Layout/SpaceAfterComma: - Enabled: true - -Layout/SpaceAfterMethodName: - Enabled: true - -Layout/SpaceAfterNot: - Enabled: true - -Layout/SpaceAfterSemicolon: - Enabled: true - -Layout/SpaceAroundBlockParameters: - Enabled: true - -Layout/SpaceAroundOperators: - Enabled: true - -Layout/SpaceBeforeBlockBraces: - Enabled: true - -Layout/SpaceBeforeComma: - Enabled: true - -Layout/SpaceBeforeComment: - Enabled: true - -Layout/SpaceBeforeFirstArg: - Enabled: true - -Layout/SpaceBeforeSemicolon: - Enabled: true - -Layout/SpaceInsideArrayLiteralBrackets: - Enabled: true - -Layout/SpaceInsideArrayPercentLiteral: - Enabled: true - -Layout/SpaceInsideBlockBraces: - Enabled: true - -Layout/SpaceInsideHashLiteralBraces: - Enabled: true - EnforcedStyle: compact - -Layout/SpaceInsideParens: - Enabled: true - -Layout/SpaceInsidePercentLiteralDelimiters: - Enabled: true - -Layout/SpaceInsideRangeLiteral: - Enabled: true - -Layout/SpaceInsideReferenceBrackets: - Enabled: true - -Layout/SpaceInsideStringInterpolation: - Enabled: true - -Layout/Tab: - Enabled: true - -Layout/TrailingBlankLines: - Enabled: true - -Layout/TrailingWhitespace: - Enabled: true - -Lint/AmbiguousRegexpLiteral: - Enabled: true - -Lint/DuplicateMethods: - Enabled: true - -Lint/LiteralAsCondition: - Enabled: true - -Lint/ParenthesesAsGroupedExpression: - Enabled: true - -Lint/ShadowingOuterLocalVariable: - Enabled: true - -Lint/StringConversionInInterpolation: - Enabled: true - -Lint/UselessAssignment: - Enabled: true - -Metrics/LineLength: - Max: 110 - Severity: refactor - -Performance/CompareWithBlock: - Enabled: true - -Performance/Detect: - Enabled: true - -Performance/DoubleStartEndWith: - Enabled: true - -Performance/EndWith: - Enabled: true - -Performance/StartWith: - Enabled: true - -Rails/ActionFilter: - Enabled: true - -Rails/ApplicationJob: - Enabled: true - -Rails/ApplicationRecord: - Enabled: true - -Rails/CreateTableWithTimestamps: - Enabled: true - Exclude: - - "db/migrate/201[5-8]*" - -Rails/Date: - Enabled: true - -Rails/DynamicFindBy: - Enabled: true - Severity: refactor - -Rails/EnumUniqueness: - Enabled: true - -Rails/EnvironmentComparison: - Enabled: true - -Rails/FindBy: - Enabled: true - -Rails/FindEach: - Enabled: true - -Rails/HasManyOrHasOneDependent: - Enabled: true - Severity: refactor - -Rails/HttpPositionalArguments: - Enabled: true - -Rails/HasAndBelongsToMany: - Enabled: true - -Rails/InverseOf: - Enabled: true - Exclude: - - "app/models/related_content.rb" - -Rails/NotNullColumn: - Enabled: true - Exclude: - - "db/migrate/201[5-7]*" - -Rails/OutputSafety: - Enabled: true - Severity: warning - Exclude: - - app/helpers/text_with_links_helper.rb - -Rails/PluralizationGrammar: - Enabled: true - -Rails/Presence: - Enabled: true - -Rails/RelativeDateConstant: - Enabled: true - -Rails/RequestReferer: - Enabled: true - -Rails/ReversibleMigration: - Enabled: true - -Rails/SafeNavigation: - Enabled: true - ConvertTry: true - -Rails/SaveBang: - Enabled: true - Severity: refactor - -Rails/SkipsModelValidations: - Enabled: true - Blacklist: - - update_attribute - Exclude: lib/acts_as_paranoid_aliases.rb - -Rails/TimeZone: - Enabled: true - -Rails/UnknownEnv: - Enabled: true - Environments: - - development - - test - - production - - preproduction - - staging - -Rails/Validation: - Enabled: true - -RSpec/AroundBlock: - Enabled: true - -RSpec/BeforeAfterAll: - Enabled: true - -RSpec/DescribedClass: - Enabled: true - EnforcedStyle: explicit - -RSpec/EmptyExampleGroup: - Enabled: true - Exclude: - - spec/factories/**/* - -RSpec/EmptyLineAfterExampleGroup: - Enabled: true - Exclude: - - spec/factories/**/* - -RSpec/ExampleWording: - Enabled: true - -RSpec/Focus: - Enabled: true - -RSpec/HookArgument: - Enabled: true - -RSpec/InstanceVariable: - Enabled: true - Exclude: - - spec/controllers/concerns/has_filters_spec.rb - - spec/controllers/concerns/has_orders_spec.rb - -RSpec/LetBeforeExamples: - Enabled: true - -RSpec/LetSetup: - Enabled: true - -RSpec/NotToNot: - Enabled: true - -RSpec/OverwritingSetup: - Enabled: true - -RSpec/RepeatedExample: - Enabled: true - -RSpec/ScatteredLet: - Enabled: true - -RSpec/ScatteredSetup: - Enabled: true - -RSpec/VoidExpect: - Enabled: true - -Security/Eval: - Enabled: true - -Security/JSONLoad: - Enabled: true - -Security/YAMLLoad: - Enabled: true - -Style/BlockDelimiters: - Enabled: true - -Style/PercentLiteralDelimiters: - Enabled: true - -Style/SafeNavigation: - Enabled: true - -Style/StringLiterals: - EnforcedStyle: double_quotes From cf361defc77e17e3dc2d73cc61ba1d006c508c2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 25 Oct 2019 03:56:15 +0200 Subject: [PATCH 8/8] Update rubocop version for hound Hound now supports rubocop 0.75. --- .hound.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.hound.yml b/.hound.yml index 70fe6df63..2c4f3544b 100644 --- a/.hound.yml +++ b/.hound.yml @@ -1,6 +1,6 @@ rubocop: config_file: .rubocop.yml - version: 0.72.0 + version: 0.75.0 scss: config_file: .scss-lint.yml erblint: