Commit 0ac15812 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'enable-cops-with-1-or-2-offenses' into 'master'

Fix Rubocop offenses for cops with 1 or 2 offenses

See merge request gitlab-org/gitlab!23506
parents c48e5552 f320219a
......@@ -52,14 +52,6 @@ Layout/ClosingParenthesisIndentation:
- 'spec/support/helpers/stub_object_storage.rb'
- 'spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: leading, trailing
Layout/DotPosition:
Exclude:
- 'app/models/concerns/relative_positioning.rb'
# Offense count: 69
# Cop supports --auto-correct.
Layout/EmptyLinesAroundArguments:
......@@ -100,12 +92,6 @@ Layout/IndentFirstParameter:
- 'spec/support/helpers/repo_helpers.rb'
- 'spec/support/helpers/stub_object_storage.rb'
# Offense count: 1
# Cop supports --auto-correct.
Layout/LeadingBlankLines:
Exclude:
- 'lib/tasks/yarn.rake'
# Offense count: 54
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
......@@ -150,11 +136,6 @@ Layout/SpaceInsideBlockBraces:
Layout/SpaceInsideParens:
Enabled: false
# Offense count: 1
Lint/DisjunctiveAssignmentInConstructor:
Exclude:
- 'app/models/uploads/base.rb'
# Offense count: 19
Lint/DuplicateMethods:
Exclude:
......@@ -177,21 +158,6 @@ Lint/DuplicateMethods:
Lint/MissingCopEnableDirective:
Enabled: false
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: Whitelist.
# Whitelist: present?, blank?, presence, try, try!
Lint/SafeNavigationConsistency:
Exclude:
- 'lib/gitlab/gpg/commit.rb'
# Offense count: 2
# Cop supports --auto-correct.
Lint/ToJSON:
Exclude:
- 'lib/gitlab/cycle_analytics/usage_data.rb'
- 'lib/gitlab/template/base_template.rb'
# Offense count: 6
Lint/UriEscapeUnescape:
Exclude:
......@@ -200,12 +166,6 @@ Lint/UriEscapeUnescape:
- 'spec/lib/google_api/auth_spec.rb'
- 'spec/requests/api/files_spec.rb'
# Offense count: 1
# Configuration parameters: CheckForMethodsWithNoSideEffects.
Lint/Void:
Exclude:
- 'lib/gitlab/git/diff_collection.rb'
# Offense count: 165
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
......@@ -284,12 +244,6 @@ RSpec/LetBeforeExamples:
- 'spec/rubocop/cop/migration/update_column_in_batches_spec.rb'
- 'spec/serializers/pipeline_details_entity_spec.rb'
# Offense count: 1
# Cop supports --auto-correct.
RSpec/MultipleSubjects:
Exclude:
- 'spec/services/merge_requests/create_from_issue_service_spec.rb'
# Offense count: 2018
# Cop supports --auto-correct.
# Configuration parameters: Strict, EnforcedStyle, AllowedExplicitMatchers.
......@@ -319,12 +273,6 @@ RSpec/ScatteredSetup:
- 'spec/requests/api/jobs_spec.rb'
- 'spec/services/projects/create_service_spec.rb'
# Offense count: 1
# Cop supports --auto-correct.
RSpec/SharedContext:
Exclude:
- 'spec/features/admin/admin_groups_spec.rb'
# Offense count: 4
RSpec/VoidExpect:
Exclude:
......@@ -348,12 +296,6 @@ Rails/ApplicationController:
- 'spec/controllers/concerns/continue_params_spec.rb'
- 'spec/lib/marginalia_spec.rb'
# Offense count: 1
# Cop supports --auto-correct.
Rails/ApplicationMailer:
Exclude:
- 'app/mailers/base_mailer.rb'
# Offense count: 8
# Cop supports --auto-correct.
Rails/BelongsTo:
......@@ -414,14 +356,6 @@ Rails/LinkToBlank:
Rails/RakeEnvironment:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/RedundantAllowNil:
Exclude:
- 'app/models/application_setting.rb'
# Offense count: 868
# Configuration parameters: Blacklist, Whitelist.
# Blacklist: decrement!, decrement_counter, increment!, increment_counter, toggle!, touch, update_all, update_attribute, update_column, update_columns, update_counters
......@@ -457,12 +391,6 @@ Style/CommentedKeyword:
- 'lib/tasks/gitlab/backup.rake'
- 'spec/tasks/gitlab/backup_rake_spec.rb'
# Offense count: 1
# Cop supports --auto-correct.
Style/Dir:
Exclude:
- 'qa/qa.rb'
# Offense count: 6
# Cop supports --auto-correct.
Style/EachWithObject:
......@@ -591,13 +519,6 @@ Style/NumericLiteralPrefix:
Style/NumericPredicate:
Enabled: false
# Offense count: 2
# Cop supports --auto-correct.
Style/OrAssignment:
Exclude:
- 'lib/api/commit_statuses.rb'
- 'lib/gitlab/project_transfer.rb'
# Offense count: 106
# Cop supports --auto-correct.
Style/ParallelAssignment:
......@@ -632,12 +553,6 @@ Style/PerlBackrefs:
Style/RaiseArgs:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
Style/RedundantConditional:
Exclude:
- 'lib/system_check/helpers.rb'
# Offense count: 221
# Cop supports --auto-correct.
Style/RedundantFreeze:
......@@ -704,12 +619,6 @@ Style/SingleLineMethods:
Style/SpecialGlobalVars:
EnforcedStyle: use_perl_names
# Offense count: 1
# Cop supports --auto-correct.
Style/StderrPuts:
Exclude:
- 'config/initializers/rspec_profiling.rb'
# Offense count: 75
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
......@@ -736,30 +645,6 @@ Style/TernaryParentheses:
- 'spec/requests/api/pipeline_schedules_spec.rb'
- 'spec/support/capybara.rb'
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInArrayLiteral:
Exclude:
- 'ee/spec/models/project_spec.rb'
- 'spec/lib/gitlab/metrics/dashboard/processor_spec.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInHashLiteral:
Exclude:
- 'lib/gitlab/ci/ansi2html.rb'
# Offense count: 2
# Cop supports --auto-correct.
Style/UnlessElse:
Exclude:
- 'lib/backup/manager.rb'
- 'lib/gitlab/project_search_results.rb'
# Offense count: 8
# Cop supports --auto-correct.
Style/UnneededCondition:
......@@ -776,13 +661,6 @@ Style/UnneededCondition:
Style/UnneededInterpolation:
Enabled: false
# Offense count: 2
# Cop supports --auto-correct.
Style/UnneededSort:
Exclude:
- 'app/models/concerns/resolvable_discussion.rb'
- 'lib/gitlab/highlight.rb'
RSpec/ReceiveCounts:
Exclude:
- 'ee/spec/models/broadcast_message_spec.rb'
......@@ -907,4 +785,4 @@ RSpec/ContextMethod:
- 'spec/services/projects/open_issues_count_service_spec.rb'
- 'spec/services/quick_actions/interpret_service_spec.rb'
- 'spec/support/shared_examples/services/boards/issues_list_service_shared_examples.rb'
- 'spec/uploaders/namespace_file_uploader_spec.rb'
\ No newline at end of file
- 'spec/uploaders/namespace_file_uploader_spec.rb'
# frozen_string_literal: true
class AbuseReportMailer < BaseMailer
class AbuseReportMailer < ApplicationMailer
layout 'empty_mailer'
helper EmailsHelper
......
# frozen_string_literal: true
class BaseMailer < ActionMailer::Base
class ApplicationMailer < ActionMailer::Base
around_action :render_with_default_locale
helper ApplicationHelper
......
# frozen_string_literal: true
class EmailRejectionMailer < BaseMailer
class EmailRejectionMailer < ApplicationMailer
layout 'empty_mailer'
helper EmailsHelper
......
# frozen_string_literal: true
class Notify < BaseMailer
class Notify < ApplicationMailer
include ActionDispatch::Routing::PolymorphicRoutes
include GitlabRoutingHelper
include EmailsHelper
......
# frozen_string_literal: true
class RepositoryCheckMailer < BaseMailer
class RepositoryCheckMailer < ApplicationMailer
# rubocop: disable CodeReuse/ActiveRecord
layout 'empty_mailer'
......
......@@ -142,7 +142,7 @@ class ApplicationSetting < ApplicationRecord
if: :auto_devops_enabled?
validates :enabled_git_access_protocol,
inclusion: { in: %w(ssh http), allow_blank: true, allow_nil: true }
inclusion: { in: %w(ssh http), allow_blank: true }
validates :domain_blacklist,
presence: { message: 'Domain blacklist cannot be empty if Blacklist is enabled.' },
......
......@@ -237,8 +237,7 @@ module RelativePositioning
relation
.pluck(self.class.relative_positioning_parent_column, Arel.sql("#{calculation}(relative_position) AS position"))
.first&.
last
.first&.last
end
def scoped_items
......
......@@ -63,7 +63,7 @@ module ResolvableDiscussion
return unless resolved?
strong_memoize(:last_resolved_note) do
resolved_notes.sort_by(&:resolved_at).last
resolved_notes.max_by(&:resolved_at)
end
end
......
......@@ -7,7 +7,7 @@ module Uploads
attr_reader :logger
def initialize(logger: nil)
@logger ||= Rails.logger # rubocop:disable Gitlab/RailsLogger
@logger = Rails.logger # rubocop:disable Gitlab/RailsLogger
end
def delete_keys_async(keys_to_delete)
......
......@@ -46,7 +46,7 @@ module RspecProfilingExt
rescue => err
return if @already_logged_example_finished_error # rubocop:disable Gitlab/ModuleWithInstanceVariables
$stderr.puts "rspec_profiling couldn't collect an example: #{err}. Further warnings suppressed."
warn "rspec_profiling couldn't collect an example: #{err}. Further warnings suppressed."
@already_logged_example_finished_error = true # rubocop:disable Gitlab/ModuleWithInstanceVariables
end
......
# frozen_string_literal: true
class CiMinutesUsageMailer < BaseMailer
class CiMinutesUsageMailer < ApplicationMailer
def notify(namespace_name, recipients)
@namespace_name = namespace_name
......
......@@ -15,7 +15,7 @@ describe Emails::ServiceDesk do
let_it_be(:issue) { create(:issue, project: project) }
let(:template) { double(content: template_content) }
class ServiceEmailClass < BaseMailer
class ServiceEmailClass < ApplicationMailer
include GitlabRoutingHelper
include EmailsHelper
include Emails::ServiceDesk
......
......@@ -1282,7 +1282,7 @@ describe Project do
:epics, # Gold only
:service_desk, # Silver and up
:audit_events, # Bronze and up
:geo, # Global feature, should not be checked at namespace level
:geo # Global feature, should not be checked at namespace level
])
end
......
......@@ -76,14 +76,12 @@ module API
name = params[:name] || params[:context] || 'default'
unless pipeline
pipeline = user_project.ci_pipelines.create!(
source: :external,
sha: commit.sha,
ref: ref,
user: current_user,
protected: user_project.protected_for?(ref))
end
pipeline ||= user_project.ci_pipelines.create!(
source: :external,
sha: commit.sha,
ref: ref,
user: current_user,
protected: user_project.protected_for?(ref))
status = GenericCommitStatus.running_or_pending.find_or_initialize_by(
project: user_project,
......
......@@ -135,11 +135,11 @@ module Backup
progress.print 'Unpacking backup ... '
unless Kernel.system(*%W(tar -xf #{tar_file}))
if Kernel.system(*%W(tar -xf #{tar_file}))
progress.puts 'done'.color(:green)
else
progress.puts 'unpacking backup failed'.color(:red)
exit 1
else
progress.puts 'done'.color(:green)
end
ENV["VERSION"] = "#{settings[:db_version]}" if settings[:db_version].to_i > 0
......
......@@ -15,7 +15,7 @@ module Gitlab
4 => 'blue',
5 => 'magenta',
6 => 'cyan',
7 => 'white', # not that this is gray in the dark (aka default) color table
7 => 'white' # not that this is gray in the dark (aka default) color table
}.freeze
STYLE_SWITCHES = {
......
......@@ -12,7 +12,7 @@ module Gitlab
@options = { from: 7.days.ago }
end
def to_json
def to_json(*)
total = 0
values =
......
......@@ -102,7 +102,7 @@ module Gitlab
def populate!
return if @populated
each { nil } # force a loop through all diffs
each {} # force a loop through all diffs
nil
end
......
......@@ -16,13 +16,13 @@ module Gitlab
def signature_text
strong_memoize(:signature_text) do
@signature_data&.itself && @signature_data[0]
@signature_data&.itself && @signature_data[0] # rubocop:disable Lint/SafeNavigationConsistency
end
end
def signed_text
strong_memoize(:signed_text) do
@signature_data&.itself && @signature_data[1]
@signature_data&.itself && @signature_data[1] # rubocop:disable Lint/SafeNavigationConsistency
end
end
......
......@@ -32,7 +32,7 @@ module Gitlab
@lexer ||= custom_language || begin
Rouge::Lexer.guess(filename: @blob_name, source: @blob_content).new
rescue Rouge::Guesser::Ambiguous => e
e.alternatives.sort_by(&:tag).first
e.alternatives.min_by(&:tag)
end
end
......
......@@ -106,10 +106,10 @@ module Gitlab
@wiki_blobs ||= begin
if project.wiki_enabled? && query.present?
unless project.wiki.empty?
Gitlab::WikiFileFinder.new(project, repository_wiki_ref).find(query)
else
if project.wiki.empty?
[]
else
Gitlab::WikiFileFinder.new(project, repository_wiki_ref).find(query)
end
else
[]
......
......@@ -32,7 +32,7 @@ module Gitlab
private
def move(path_was, path, base_dir = nil)
base_dir = root_dir unless base_dir
base_dir ||= root_dir
from = File.join(base_dir, path_was)
to = File.join(base_dir, path)
FileUtils.mv(from, to)
......
......@@ -33,7 +33,7 @@ module Gitlab
self
end
def to_json
def to_json(*)
{ key: key, name: name, content: content }
end
......
......@@ -57,11 +57,7 @@ module SystemCheck
end
def should_sanitize?
if ENV['SANITIZE'] == 'true'
true
else
false
end
ENV['SANITIZE'] == 'true'
end
def omnibus_gitlab?
......
# frozen_string_literal: true
namespace :yarn do
desc 'Ensure Yarn is installed'
......
# frozen_string_literal: true
$: << File.expand_path(File.dirname(__FILE__))
$: << File.expand_path(__dir__)
Encoding.default_external = 'UTF-8'
......
......@@ -134,7 +134,7 @@ describe 'Admin Groups' do
end
describe 'add user into a group', :js do
shared_context 'adds user into a group' do
shared_examples 'adds user into a group' do
it do
visit admin_group_path(group)
......
......@@ -62,7 +62,7 @@ describe Gitlab::Metrics::Dashboard::Processor do
'metric_a1', # group priority 1, panel weight 1
project_business_metric.id, # group priority 0, panel weight nil (0)
project_response_metric.id, # group priority -5, panel weight nil (0)
project_system_metric.id, # group priority -10, panel weight nil (0)
project_system_metric.id # group priority -10, panel weight nil (0)
]
actual_metrics_order = all_metrics.map { |m| m[:id] || m[:metric_id] }
......
......@@ -18,7 +18,7 @@ describe 'Marginalia spec' do
end
end
class MarginaliaTestMailer < BaseMailer
class MarginaliaTestMailer < ApplicationMailer
def first_user
User.first
end
......
......@@ -11,10 +11,8 @@ describe MergeRequests::CreateFromIssueService do
let(:milestone_id) { create(:milestone, project: project).id }
let(:issue) { create(:issue, project: project, milestone_id: milestone_id) }
let(:custom_source_branch) { 'custom-source-branch' }
subject(:service) { described_class.new(project, user, service_params) }
subject(:service_with_custom_source_branch) { described_class.new(project, user, branch_name: custom_source_branch, **service_params) }
let(:service) { described_class.new(project, user, service_params) }
let(:service_with_custom_source_branch) { described_class.new(project, user, branch_name: custom_source_branch, **service_params) }
before do
project.add_developer(user)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment