Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rubocop fixes #1640

Merged
merged 13 commits into from
Aug 4, 2020
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ Metrics/ClassLength:
Exclude:
- 'app/controllers/catalog_controller.rb'

Metrics/ModuleLength:
Max: 200

Rails/HasAndBelongsToMany:
Exclude:
- 'app/models/role.rb'
Expand Down
216 changes: 141 additions & 75 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,120 +1,186 @@
# Turn on RSpec cops
require: rubocop-rspec
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-08-30 08:01:37 -0500 using RuboCop version 0.42.0.
# on 2020-05-15 17:53:23 +0000 using RuboCop version 0.52.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.

Style/FrozenStringLiteralComment:
Enabled: false

Style/SafeNavigation:
Enabled: false
# Offense count: 1
Lint/AmbiguousBlockAssociation:
Exclude:
- 'app/controllers/catalog_controller.rb'

Metrics/MethodLength:
# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect.
# SupportedStylesAlignWith: keyword, variable, start_of_line
Lint/EndAlignment:
Exclude:
- 'app/jobs/import_work_from_purl_job.rb'
- 'spec/support/rake.rb'
- 'app/helpers/blacklight/catalog_helper_behavior.rb'

RSpec/SubjectStub:
# Offense count: 2
Lint/UselessAssignment:
Exclude:
- 'spec/models/solr_endpoint_spec.rb'
- 'app/forms/hyrax/forms/admin/appearance.rb'
- 'spec/controllers/proprietor/users_controller_spec.rb'

# Offense count: 10
RSpec/LeadingSubject:
Exclude:
- 'spec/controllers/hyrax/generic_works_controller_spec.rb'
- 'spec/helpers/admin_stats_helper_spec.rb'
- 'spec/lib/active_job_tenant_spec.rb'
- 'spec/lib/importer/factory/string_literal_processor_spec.rb'
- 'spec/lib/stanford/importer/mods_parser_spec.rb'
- 'spec/services/create_account_spec.rb'
- 'spec/services/iiif_thumbnail_path_service_spec.rb'
- 'spec/services/solr_config_uploader_spec.rb'

# Offense count: 13
RSpec/LetSetup:
Exclude:
- 'spec/lib/importer/factory/etd_factory_spec.rb'
- 'spec/lib/importer/factory/image_factory_spec.rb'
- 'spec/lib/stanford/importer/purl_importer_spec.rb'
- 'spec/models/account_spec.rb'
- 'spec/models/role_spec.rb'
- 'spec/models/user_spec.rb'
Metrics/AbcSize:
Max: 49

# Offense count: 3
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 112

# Offense count: 2
Metrics/CyclomaticComplexity:
Max: 12

# Offense count: 23
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 376

# Offense count: 7
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 35

# Offense count: 4
# Configuration parameters: MaxNesting.
RSpec/NestedGroups:
Exclude:
- 'spec/services/iiif_authorization_service_spec.rb'
# Offense count: 1
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 168

RSpec/ContextWording:
Enabled: false
# Offense count: 2
Metrics/PerceivedComplexity:
Max: 14

RSpec/IteratedExpectation:
# Offense count: 1
# Configuration parameters: Blacklist.
# Blacklist: END, (?-mix:EO[A-Z]{1})
Naming/HeredocDelimiterNaming:
Exclude:
- 'spec/tasks/rake_spec.rb'
- 'spec/jobs/import_work_from_purl_job_spec.rb'

RSpec/BeforeAfterAll:
# Offense count: 6
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros.
# NamePrefix: is_, has_, have_
# NamePrefixBlacklist: is_, has_, have_
# NameWhitelist: is_a?
# MethodDefinitionMacros: define_method, define_singleton_method
Naming/PredicateName:
Exclude:
- 'spec/tasks/rake_spec.rb'
- 'spec/models/uploaded_file_spec.rb'
- 'spec/**/*'
- 'app/controllers/application_controller.rb'
- 'app/helpers/blacklight/catalog_helper_behavior.rb'
- 'app/models/user.rb'

Style/MixinUsage:
# Offense count: 6
RSpec/BeforeAfterAll:
Exclude:
- 'spec/support/devise.rb'
- 'spec/features/create_image_spec.rb'
- 'spec/spec_helper.rb'
- 'spec/rails_helper.rb'
- 'spec/support/**/*.rb'
- 'spec/models/hyku/group_spec.rb'
- 'spec/models/uploaded_file_spec.rb'
- 'spec/tasks/rake_spec.rb'

RSpec/ScatteredLet:
# Offense count: 85
# Configuration parameters: Prefixes.
# Prefixes: when, with, without
RSpec/ContextWording:
Enabled: false

RSpec/HookArgument:
# Offense count: 3
RSpec/ExpectInHook:
Exclude:
- 'spec/rails_helper.rb'
- 'spec/controllers/sites_controller_spec.rb'
- 'spec/models/uploaded_file_spec.rb'

RSpec/ExpectInHook:
# Offense count: 1
RSpec/IteratedExpectation:
Exclude:
- 'spec/models/uploaded_file_spec.rb'
- 'spec/controllers/sites_controller_spec.rb'
Style/FormatStringToken:
- 'spec/tasks/rake_spec.rb'

# Offense count: 4
RSpec/LetSetup:
Exclude:
- 'spec/models/account_spec.rb'
- 'app/models/account.rb'

Rails/ApplicationJob:
Enabled: false

Rails/ApplicationRecord:
Enabled: false
- 'spec/models/role_spec.rb'
- 'spec/models/user_spec.rb'

RSpec/BeforeAfterAll:
# Offense count: 2
RSpec/MessageChain:
Exclude:
- 'spec/models/hyku/group_spec.rb'
- 'spec/tasks/rake_spec.rb'
- 'spec/models/uploaded_file_spec.rb'
- 'spec/views/shared/select_work_type_modal.html.erb_spec.rb'

Naming/HeredocDelimiterNaming:
# Offense count: 8
RSpec/ScatteredLet:
Exclude:
- 'spec/controllers/account_sign_up_controller_spec.rb'
- 'spec/controllers/admin/accounts_controller_spec.rb'
- 'spec/controllers/proprietor/accounts_controller_spec.rb'
- 'spec/jobs/import_work_from_purl_job_spec.rb'

# Offense count: 1
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/HasManyOrHasOneDependent:
Exclude:
- 'app/models/endpoint.rb'

FactoryBot/DynamicAttributeDefinedStatically:
# Offense count: 5
Rails/OutputSafety:
Exclude:
- 'spec/factories/users.rb'
- 'app/forms/hyrax/forms/admin/appearance.rb'
- 'app/helpers/blacklight/catalog_helper_behavior.rb'

Performance/RegexpMatch:
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Exclude:
- 'app/helpers/blacklight/catalog_helper_behavior.rb'

# Offense count: 3
# Configuration parameters: EnforcedStyle.
# SupportedStyles: annotated, template, unannotated
Style/FormatStringToken:
Exclude:
- 'lib/importer/csv_parser.rb'
- 'app/services/solr_config_uploader.rb'
- 'app/models/account.rb'
- 'spec/models/account_spec.rb'

ClassLength:
Max: 120
# Offense count: 4
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Exclude:
- 'app/controllers/application_controller.rb'
- 'app/controllers/hyrax/downloads_controller.rb'
- 'app/helpers/blacklight/catalog_helper_behavior.rb'
- 'app/models/bulkrax/entry.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: line_count_dependent, lambda, literal
Style/Lambda:
Exclude:
- 'app/models/user.rb'

# Offense count: 1
Style/MixinUsage:
Exclude:
- 'spec/support/devise.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle.
# SupportedStyles: predicate, comparison
Style/NumericPredicate:
Exclude:
- 'spec/**/*'
- 'app/helpers/blacklight/catalog_helper_behavior.rb'
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
Expand Down
2 changes: 2 additions & 0 deletions app/actors/hyrax/actors/generic_work_actor.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Generated via
# `rails generate hyrax:work GenericWork`
module Hyrax
Expand Down
2 changes: 2 additions & 0 deletions app/actors/hyrax/actors/image_actor.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Generated via
# `rails generate hyrax:work Image`
module Hyrax
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/account_sign_up_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class AccountSignUpController < ProprietorController
load_and_authorize_resource instance_name: :account, class: 'Account'

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/admin/accounts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Admin
class AccountsController < AdminController
before_action :set_current_account
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/admin/group_users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# frozen_string_literal: true

module Admin
class GroupUsersController < AdminController
before_action :load_group

# rubocop:disable Metrics/AbcSize
def index
add_breadcrumb t(:'hyrax.controls.home'), root_path
add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path
Expand All @@ -11,7 +12,6 @@ def index
@users = @group.search_members(params[:q]).page(page_number).per(page_size)
render template: 'admin/groups/users'
end
# rubocop:enable Metrics/AbcSize

def add
@group.add_members_by_id(params[:user_ids])
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/admin/groups_controller.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# frozen_string_literal: true

module Admin
class GroupsController < AdminController
before_action :load_group, only: %i[edit update remove destroy]

# rubocop:disable Metrics/AbcSize
def index
add_breadcrumb t(:'hyrax.controls.home'), root_path
add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path
add_breadcrumb t(:'hyku.admin.groups.title.index'), admin_groups_path
@groups = Hyku::Group.search(params[:q]).page(page_number).per(page_size)
end
# rubocop:enable Metrics/AbcSize

def new
add_breadcrumb t(:'hyrax.controls.home'), root_path
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Admin
class UsersController < AdminController
before_action :load_user, only: [:destroy]
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/admin/work_types_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Admin
class WorkTypesController < ApplicationController
layout 'hyrax/dashboard'
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# TODO: move to hyrax?
class AdminController < ApplicationController
before_action :ensure_admin!
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApplicationController < ActionController::Base
include HykuHelper
# Prevent CSRF attacks by raising an exception.
Expand Down Expand Up @@ -39,7 +41,7 @@ def require_active_account!
end

def set_account_specific_connections!
current_account.switch! if current_account
current_account&.switch!
end

def multitenant?
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class CatalogController < ApplicationController
include Hydra::Catalog
include Hydra::Controller::ControllerBehavior
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/contacts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ContactsController < SitesController
# GET /sites/1/edit
def edit
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/hyku/invitations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Hyku
class InvitationsController < Devise::InvitationsController
# For devise_invitable, specify post-invite path to be 'Manage Users' form
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/hyku/registrations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Hyku
class RegistrationsController < Devise::RegistrationsController
before_action :configure_permitted_parameters
Expand Down
Loading