Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
81 changes: 72 additions & 9 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
inherit_gem:
rubocop-rails-omakase: rubocop.yml

require:
plugins:
- rubocop-capybara
- rubocop-factory_bot
- rubocop-rails
Expand All @@ -11,9 +11,18 @@ require:

Rails:
Enabled: true

AllCops:
TargetRubyVersion: 3.4
TargetRailsVersion: 8.1
Exclude:
# do not worry about old migrations
- 'db/migrate/201*'
- 'db/migrate/2020*'
- 'db/migrate/2021*'
- 'db/migrate/2022*'
- 'db/migrate/2023*'
- 'db/migrate/2024*'

Style/StringLiterals:
EnforcedStyle: single_quotes
Expand Down Expand Up @@ -126,6 +135,16 @@ Layout/IndentationWidth:
Layout/ClosingParenthesisIndentation:
Enabled: true

Layout/EmptyLinesAfterModuleInclusion:
Enabled: true

Layout/EmptyLineAfterMultilineCondition:
Enabled: true

Style/ParenthesesAroundCondition:
Enabled: true
AllowInMultilineConditions: true

# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
# SupportedStyles: space, no_space
Layout/SpaceInsideHashLiteralBraces:
Expand Down Expand Up @@ -191,7 +210,23 @@ Layout/HashAlignment:
Rails/NotNullColumn:
Enabled: false

Rails/ExampleLength:
Rails/UnknownEnv:
Enabled: true
Environments:
- development
- test
- staging
- production

##
# Increase the limit of these advisory cops.
RSpec/NestedGroups:
Max: 10

RSpec/MultipleMemoizedHelpers:
Max: 10

RSpec/ExampleLength:
Enabled: true
Max: 10
CountAsOne:
Expand All @@ -200,13 +235,19 @@ Rails/ExampleLength:
- heredoc
- method_call

Rails/UnknownEnv:
Enabled: true
Environments:
- development
- test
- staging
- production
# TODO: Not enabled as too many changes required for now.
RSpec/ContextWording:
Enabled: false
RSpec/DescribedClass:
Enabled: false
RSpec/DescribeSymbol:
Enabled: false
RSpec/InstanceVariable:
Enabled: false
RSpec/NamedSubject:
Enabled: false
RSpec/SharedExamples:
Enabled: false

Style/Documentation:
Enabled: false
Expand Down Expand Up @@ -565,6 +606,20 @@ Rails/WhereNotWithMultipleConditions: # new in 2.17
Enabled: true
Rails/WhereRange: # new in 2.25
Enabled: true
Rails/EnumSyntax: # new in 2.26
Enabled: true
Rails/FindByOrAssignmentMemoization: # new in 2.33
Enabled: true
Rails/HttpStatusNameConsistency: # new in 2.34
Enabled: true
Rails/MultipleRoutePaths: # new in 2.29
Enabled: true
Rails/OrderArguments: # new in 2.33
Enabled: true
Rails/RedirectBackOrTo: # new in 2.34
Enabled: true
Rails/StrongParametersExpect: # new in 2.29
Enabled: true

Capybara/ClickLinkOrButtonStyle: # new in 2.19
Enabled: true
Expand All @@ -584,6 +639,10 @@ Capybara/RSpec/HaveSelector: # new in 2.19
Enabled: true
Capybara/RSpec/PredicateMatcher: # new in 2.19
Enabled: true
Capybara/FindAllFirst: # new in 2.22
Enabled: true
Capybara/NegationMatcherAfterVisit: # new in 2.22
Enabled: true
FactoryBot/AssociationStyle: # new in 2.23
Enabled: true
FactoryBot/ConsistentParenthesesStyle: # new in 2.14
Expand Down Expand Up @@ -612,3 +671,7 @@ RSpecRails/NegationBeValid: # new in 2.23
Enabled: true
RSpecRails/TravelAround: # new in 2.19
Enabled: true
RSpec/IncludeExamples: # new in 3.6
Enabled: true
RSpec/LeakyLocalVariable: # new in 3.8
Enabled: true
2 changes: 2 additions & 0 deletions app/controllers/activities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def activities
if linechart_start_date < 1.year.ago
linechart_start_date = 1.year.ago
end

linechart_end_date = Time.now
@start_week = params[:start_week] && Date.parse(params[:start_week])
topten_start_date, topten_end_date =
Expand All @@ -15,6 +16,7 @@ def activities
else
[ linechart_start_date, linechart_end_date ]
end

@toptens_cites = TaxonConceptViewStats.new(
topten_start_date, topten_end_date, Taxonomy::CITES_EU
).results
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/ahoy_events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ class Admin::AhoyEventsController < Admin::SimpleCrudController
authorize_resource class: 'Ahoy::Event'

def index
@ahoy_events = Ahoy::Event.order('time DESC').page(params[:page])
@ahoy_events = Ahoy::Event.order(time: :desc).page(params[:page])
end
end
2 changes: 1 addition & 1 deletion app/controllers/admin/ahoy_visits_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ class Admin::AhoyVisitsController < Admin::SimpleCrudController
authorize_resource class: 'Ahoy::Visit'

def index
@ahoy_visits = Ahoy::Visit.order('started_at DESC').page(params[:page])
@ahoy_visits = Ahoy::Visit.order(started_at: :desc).page(params[:page])
end
end
2 changes: 1 addition & 1 deletion app/controllers/admin/change_types_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def collection
@change_types ||= end_of_association_chain.includes(
:designation
).order(
'designation_id, name'
:designation_id, :name
).page(
params[:page]
).search(
Expand Down
6 changes: 4 additions & 2 deletions app/controllers/admin/cites_captivity_processes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ def create
),
notice: 'Operation successful'
end

failure.html do
load_search
render 'new'
end
end
end

def update
update! do |success, failure|
success.html do
Expand All @@ -26,6 +28,7 @@ def update
),
notice: 'Operation successful'
end

failure.html do
load_lib_objects
load_search
Expand All @@ -34,7 +37,6 @@ def update
end
end


protected

def load_lib_objects
Expand All @@ -44,7 +46,7 @@ def load_lib_objects
@status = CitesCaptivityProcess::STATUS
@events = Event.where(
"type IN ('CitesAc','CitesPc')"
).order('effective_at DESC')
).order(effective_at: :desc)
end

def collection
Expand Down
6 changes: 4 additions & 2 deletions app/controllers/admin/cites_suspensions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def create
redirect_to admin_cites_suspensions_url,
notice: 'Operation successful'
end

failure.html do
load_lib_objects
render 'new'
Expand All @@ -20,6 +21,7 @@ def update
redirect_to admin_cites_suspensions_url,
notice: 'Operation successful'
end

failure.html do
load_lib_objects
render 'edit'
Expand Down Expand Up @@ -50,13 +52,13 @@ def load_lib_objects
@suspension_notifications = CitesSuspensionNotification.select(
[ :id, :name ]
).order(
'effective_at DESC'
effective_at: :desc
)
end

def collection
@cites_suspensions ||= end_of_association_chain.order(
'start_date DESC'
start_date: :desc
).page(
params[:page]
).search(
Expand Down
1 change: 1 addition & 0 deletions app/controllers/admin/designations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Admin::DesignationsController < Admin::StandardAuthorizationController
def index
load_associations
@custom_title = 'MEAs'

index! do |format|
format.json do
render json: end_of_association_chain.order(:name).
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/admin/distributions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,39 @@ def create
@distribution.add_existing_references(params['reference']['id'])
end
end

failure.js do
load_tags_and_geo_entities
render 'new'
end
end
end

def update
update! do |success, failure|
success.js do
load_distributions
if params['reference']['id'].present?
@distribution.add_existing_references(params['reference']['id'])
end

render 'create'
end

failure.js do
load_tags_and_geo_entities
render 'new'
end
end
end


def destroy
destroy! do |success, failure|
success.html do
redirect_to admin_taxon_concept_distributions_url(@taxon_concept),
notice: 'Operation succeeded'
end

failure.html do
redirect_to admin_taxon_concept_distributions_url(@taxon_concept),
notice: 'Operation failed'
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/documents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def edit
def update
update! do |success, failure|
success.html { success_redirect }

failure.html do
load_associations
render 'new'
Expand All @@ -67,7 +68,6 @@ def destroy
end
end


def autocomplete
title = params[:title]
event_id = params[:event_id]
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/ec_srgs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Admin::EcSrgsController < Admin::EventsController

def collection
@ec_srgs ||= end_of_association_chain.order(
'designation_id, effective_at DESC'
:designation_id, effective_at: :desc
).includes(:designation).page(
params[:page]
).search(
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/eu_council_regulations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Admin::EuCouncilRegulationsController < Admin::EventsController

def collection
@eu_council_regulations ||= end_of_association_chain.order(
'effective_at DESC, name ASC'
effective_at: :desc, name: :asc
).page(
params[:page]
).search(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Admin::EuImplementingRegulationsController < Admin::EventsController

def collection
@eu_implementing_regulations ||= end_of_association_chain.order(
'effective_at DESC, name ASC'
effective_at: :desc, name: :asc
).page(
params[:page]
).search(
Expand Down
5 changes: 2 additions & 3 deletions app/controllers/admin/eu_opinions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def update
end
end


protected

def load_lib_objects
Expand All @@ -49,12 +48,12 @@ def load_lib_objects
@ec_srgs = Event.where(
"type = 'EcSrg' OR
type = 'EuRegulation' AND name IN ('No 338/97', 'No 938/97', 'No 750/2013')"
).order('effective_at DESC')
).order(effective_at: :desc)
# this will only return intersessional docs
@documents = Document.where(
"event_id IS NULL AND type = 'Document::CommissionNotes'"
).order(
'date DESC, title'
date: :desc, title: :asc
)
end

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/admin/eu_regulations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def deactivate

def collection
@eu_regulations ||= end_of_association_chain.order(
'effective_at DESC, name ASC'
effective_at: :desc, name: :asc
).page(
params[:page]
).search(
Expand All @@ -29,7 +29,7 @@ def collection

def load_associations
@eu_regulations_for_dropdown = EuRegulation.
order('effective_at DESC, name ASC')
order(effective_at: :desc, name: :asc)
end

private
Expand Down
Loading