Skip to content

Commit

Permalink
Merge pull request consuldemocracy#3636 from consul/change_basic_rubo…
Browse files Browse the repository at this point in the history
…cop_rules

Change basic rubocop rules
  • Loading branch information
javierm committed Sep 10, 2019
2 parents 025c361 + c904647 commit 105a8cc
Show file tree
Hide file tree
Showing 80 changed files with 222 additions and 243 deletions.
69 changes: 0 additions & 69 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
inherit_from: .rubocop_basic.yml

Bundler/DuplicatedGem:
Enabled: true

Bundler/InsecureProtocolSource:
Enabled: true

Bundler/OrderedGems:
Enabled: true

Gemspec/DuplicatedAssignment:
Enabled: true

Expand Down Expand Up @@ -141,12 +135,6 @@ Rails/Output:
Rails/OutputSafety:
Enabled: true

Rails/PluralizationGrammar:
Enabled: true

Rails/Presence:
Enabled: true

Rails/Present:
Enabled: true

Expand All @@ -156,15 +144,9 @@ Rails/ReadWriteAttribute:
Rails/RedundantReceiverInWithOptions:
Enabled: true

Rails/RequestReferer:
Enabled: true

Rails/ReversibleMigration:
Enabled: true

Rails/SafeNavigation:
Enabled: true

Rails/SaveBang:
Enabled: true

Expand All @@ -177,12 +159,6 @@ Rails/SkipsModelValidations:
Rails/UniqBeforePluck:
Enabled: true

Rails/UnknownEnv:
Enabled: true

Rails/Validation:
Enabled: true

RSpec/AlignLeftLetBrace:
Enabled: false

Expand All @@ -192,18 +168,9 @@ RSpec/AlignRightLetBrace:
RSpec/AnyInstance:
Enabled: false

RSpec/AroundBlock:
Enabled: true

RSpec/BeEql:
Enabled: true

RSpec/BeforeAfterAll:
Enabled: true

Capybara/CurrentPathExpectation:
Enabled: true

Capybara/FeatureMethods:
Enabled: false

Expand All @@ -219,18 +186,9 @@ RSpec/DescribeMethod:
RSpec/DescribeSymbol:
Enabled: true

RSpec/EmptyExampleGroup:
Enabled: true

RSpec/EmptyLineAfterSubject:
Enabled: true

RSpec/ExampleLength:
Enabled: false

RSpec/ExampleWording:
Enabled: true

RSpec/ExpectActual:
Enabled: true

Expand All @@ -243,12 +201,6 @@ RSpec/ExpectOutput:
RSpec/FilePath:
Enabled: true

RSpec/Focus:
Enabled: true

RSpec/HookArgument:
Enabled: true

RSpec/ImplicitExpect:
Enabled: true
EnforcedStyle: should
Expand All @@ -271,12 +223,6 @@ RSpec/IteratedExpectation:
RSpec/LeadingSubject:
Enabled: true

RSpec/LetBeforeExamples:
Enabled: true

RSpec/LetSetup:
Enabled: true

RSpec/MessageChain:
Enabled: true

Expand All @@ -303,9 +249,6 @@ RSpec/NestedGroups:
Enabled: true
Max: 4

RSpec/OverwritingSetup:
Enabled: true

RSpec/PredicateMatcher:
Enabled: true

Expand All @@ -315,18 +258,9 @@ Rails/HttpStatus:
RSpec/RepeatedDescription:
Enabled: true

RSpec/RepeatedExample:
Enabled: true

RSpec/ReturnFromStub:
Enabled: true

RSpec/ScatteredLet:
Enabled: true

RSpec/ScatteredSetup:
Enabled: true

RSpec/SharedContext:
Enabled: true

Expand All @@ -339,9 +273,6 @@ RSpec/SubjectStub:
RSpec/VerifiedDoubles:
Enabled: true

RSpec/VoidExpect:
Enabled: true

Security/Eval:
Enabled: true

Expand Down
80 changes: 80 additions & 0 deletions .rubocop_basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ AllCops:
# 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:
Expand Down Expand Up @@ -129,15 +138,86 @@ Rails/Date:
Rails/HttpPositionalArguments:
Enabled: true

Rails/PluralizationGrammar:
Enabled: true

Rails/Presence:
Enabled: true

Rails/RelativeDateConstant:
Enabled: true

Rails/RequestReferer:
Enabled: true

Rails/SafeNavigation:
Enabled: true
ConvertTry: true

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/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/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

Style/PercentLiteralDelimiters:
Enabled: true

Expand Down
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ gem "acts_as_votable", "~> 0.11.1"
gem "ahoy_matey", "~> 1.6.0"
gem "ancestry", "~> 3.0.2"
gem "autoprefixer-rails", "~> 8.2.0"
gem "axlsx", "~> 3.0.0.pre"
gem "axlsx_rails", "~> 0.5.2"
gem "browser", "~> 2.5.3"
gem "cancancan", "~> 2.3.0"
gem "ckeditor", "~> 4.2.3"
Expand Down Expand Up @@ -40,6 +42,7 @@ gem "paperclip", "~> 5.2.1"
gem "paranoia", "~> 2.4.1"
gem "pg", "~> 0.21.0"
gem "pg_search", "~> 2.0.1"
gem "recipient_interceptor", "~> 0.2.0"
gem "redcarpet", "~> 3.4.0"
gem "responders", "~> 2.4.0"
gem "rinku", "~> 2.0.2", require: "rails_rinku"
Expand All @@ -55,11 +58,8 @@ gem "turnout", "~> 2.4.0"
gem "uglifier", "~> 4.1.2"
gem "unicorn", "~> 5.4.1"
gem "whenever", "~> 0.10.0", require: false
gem "recipient_interceptor", "~> 0.2.0"
gem "wkhtmltopdf-binary", "~> 0.12.4"
gem "wicked_pdf", "~> 1.1.0"
gem "axlsx", "~> 3.0.0.pre"
gem "axlsx_rails", "~> 0.5.2"
gem "wkhtmltopdf-binary", "~> 0.12.4"

source "https://rails-assets.org" do
gem "rails-assets-leaflet"
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Admin::BaseController < ApplicationController
private

def verify_administrator
raise CanCan::AccessDenied unless current_user.try(:administrator?)
raise CanCan::AccessDenied unless current_user&.administrator?
end

end
2 changes: 1 addition & 1 deletion app/controllers/admin/legislation/homepages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def edit
def update
if @process.update(process_params)
link = legislation_process_path(@process).html_safe
redirect_back(fallback_location: (request.referrer || root_path),
redirect_back(fallback_location: (request.referer || root_path),
notice: t("admin.legislation.processes.update.notice", link: link))
else
flash.now[:error] = t("admin.legislation.processes.update.error")
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/legislation/processes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def update
set_tag_list

link = legislation_process_path(@process).html_safe
redirect_back(fallback_location: (request.referrer || root_path),
redirect_back(fallback_location: (request.referer || root_path),
notice: t("admin.legislation.processes.update.notice", link: link))
else
flash.now[:error] = t("admin.legislation.processes.update.error")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def destroy
else
t("flash.actions.destroy.error")
end
redirect_back(fallback_location: (request.referrer || root_path), notice: notice)
redirect_back(fallback_location: (request.referer || root_path), notice: notice)
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/poll/questions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def new
end

def create
@question.author = @question.proposal.try(:author) || current_user
@question.author = @question.proposal&.author || current_user
@question.votation_type = VotationType.build_by_type(@question, params[:votation_type])

if @question.save
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ def set_return_url
end

def set_default_budget_filter
if @budget.try(:balloting?) || @budget.try(:publishing_prices?)
if @budget&.balloting? || @budget&.publishing_prices?
params[:filter] ||= "selected"
elsif @budget.try(:finished?)
elsif @budget&.finished?
params[:filter] ||= "winners"
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/budgets/investments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def load_ballot
def load_heading
if params[:heading_id].present?
@heading = @budget.headings.find_by_slug_or_id! params[:heading_id]
@assigned_heading = @ballot.try(:heading_for_group, @heading.try(:group))
@assigned_heading = @ballot&.heading_for_group(@heading&.group)
load_map
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def moderator_comment?

def add_notification(comment)
notifiable = comment.reply? ? comment.parent : comment.commentable
notifiable_author_id = notifiable.try(:author_id)
notifiable_author_id = notifiable&.author_id
if notifiable_author_id.present? && notifiable_author_id != comment.author_id
Notification.add(notifiable.author, notifiable)
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/management/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ def destroy_session
end

def admin?
if current_user.try(:administrator?)
if current_user&.administrator?
session[:manager] = { login: "admin_user_#{current_user.id}" }
end
end

def manager?
if current_user.try(:manager?)
if current_user&.manager?
session[:manager] = { login: "manager_user_#{current_user.id}" }
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/moderation/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Moderation::BaseController < ApplicationController
private

def verify_moderator
raise CanCan::AccessDenied unless current_user.try(:moderator?) || current_user.try(:administrator?)
raise CanCan::AccessDenied unless current_user&.moderator? || current_user&.administrator?
end

end
Loading

0 comments on commit 105a8cc

Please sign in to comment.