Skip to content

Commit

Permalink
[ci] Remove dependency of rubocop rake task gem
Browse files Browse the repository at this point in the history
Using the rubocop rake task gem was forcing us to either include
this gem in any environment, including production, or disable the
rake task in such cases.
Since we also had problems with combining both OBS rubocop suites
when using RuboCop::RakeTask (see PR#5219) we go back to calling
rubocop from console.
  • Loading branch information
bgeuken committed Jun 27, 2018
1 parent ad5379e commit c263005
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 92 deletions.
2 changes: 1 addition & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2018-06-22 07:45:47 +0000 using RuboCop version 0.57.2.
# on 2018-06-27 11:15:49 +0000 using RuboCop version 0.57.2.
# 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
Expand Down
64 changes: 13 additions & 51 deletions src/api/.rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2018-06-26 13:56:08 +0000 using RuboCop version 0.57.2.
# on 2018-06-27 11:19:32 +0000 using RuboCop version 0.57.2.
# 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
Expand All @@ -25,12 +25,11 @@ FactoryBot/DynamicAttributeDefinedStatically:
- 'spec/factories/issue.rb'
- 'spec/factories/issue_tracker.rb'

# Offense count: 3
# Offense count: 2
# Cop supports --auto-correct.
Layout/AlignArray:
Exclude:
- 'app/models/obs_factory/distribution.rb'
- 'app/models/obs_factory/staging_project.rb'

# Offense count: 233
# Cop supports --auto-correct.
Expand Down Expand Up @@ -191,20 +190,6 @@ Layout/SpaceAfterComma:
- 'app/controllers/webui/obs_factory/staging_projects_controller.rb'
- 'app/models/obs_factory/distribution.rb'

# Offense count: 2
# Cop supports --auto-correct.
Layout/SpaceAfterNot:
Exclude:
- 'app/models/obs_factory/staging_project.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: space, no_space
Layout/SpaceAroundEqualsInParameterDefault:
Exclude:
- 'app/models/obs_factory/staging_project.rb'

# Offense count: 30
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment.
Expand All @@ -220,15 +205,6 @@ Layout/SpaceAroundOperators:
- 'test/functional/request_controller_test.rb'
- 'test/functional/search_controller_test.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets.
# SupportedStyles: space, no_space, compact
# SupportedStylesForEmptyBrackets: space, no_space
Layout/SpaceInsideArrayLiteralBrackets:
Exclude:
- 'app/models/obs_factory/staging_project.rb'

# Offense count: 10
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
Expand Down Expand Up @@ -827,14 +803,13 @@ Rails/CreateTableWithTimestamps:
- 'db/migrate/20160321105300_request_counter.rb'
- 'db/migrate/20171030143054_create_kiwi_preference_types.rb'

# Offense count: 5
# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforceForPrefixed.
Rails/Delegate:
Exclude:
- 'app/models/obs_factory/distribution.rb'
- 'app/models/obs_factory/obs_project.rb'
- 'app/models/obs_factory/staging_project.rb'

# Offense count: 85
# Configuration parameters: EnforcedStyle.
Expand Down Expand Up @@ -940,12 +915,11 @@ Security/Open:
- 'app/models/obs_factory/distribution_strategy_factory.rb'
- 'app/models/obs_factory/distribution_strategy_opensuse.rb'

# Offense count: 2
# Offense count: 1
# Cop supports --auto-correct.
Security/YAMLLoad:
Exclude:
- 'app/controllers/webui/obs_factory/staging_projects_controller.rb'
- 'app/models/obs_factory/staging_project.rb'

# Offense count: 28
# Configuration parameters: EnforcedStyle.
Expand Down Expand Up @@ -1099,7 +1073,7 @@ Style/FormatStringToken:
Style/FrozenStringLiteralComment:
Enabled: false

# Offense count: 9
# Offense count: 8
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Exclude:
Expand All @@ -1122,12 +1096,12 @@ Style/IdenticalConditionalBranches:
- 'app/controllers/build_controller.rb'
- 'app/controllers/webui/search_controller.rb'

# Offense count: 306
# Offense count: 305
# Cop supports --auto-correct.
Style/IfUnlessModifier:
Enabled: false

# Offense count: 11
# Offense count: 10
# Cop supports --auto-correct.
# Configuration parameters: InverseMethods, InverseBlocks.
Style/InverseMethods:
Expand All @@ -1136,7 +1110,6 @@ Style/InverseMethods:
- 'app/models/bs_request.rb'
- 'app/models/bs_request_action_submit.rb'
- 'app/models/bs_request_permission_check.rb'
- 'app/models/obs_factory/staging_project.rb'
- 'app/models/package.rb'
- 'app/models/project.rb'
- 'app/views/source/_common_issues.xml.builder'
Expand Down Expand Up @@ -1179,21 +1152,12 @@ Style/MultipleComparison:
- 'lib/tasks/extract.rake'
- 'script/reformat_memprof'

# Offense count: 7
# Offense count: 4
# Cop supports --auto-correct.
Style/MutableConstant:
Exclude:
- 'app/models/obs_factory/distribution.rb'
- 'app/models/obs_factory/request.rb'
- 'app/models/obs_factory/staging_project.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, MinBodyLength.
# SupportedStyles: skip_modifier_ifs, always
Style/Next:
Exclude:
- 'app/models/obs_factory/staging_project.rb'

# Offense count: 6
# Cop supports --auto-correct.
Expand All @@ -1208,7 +1172,7 @@ Style/NumericLiterals:
Style/NumericPredicate:
Enabled: false

# Offense count: 20
# Offense count: 13
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Expand All @@ -1217,7 +1181,6 @@ Style/PercentLiteralDelimiters:
- 'app/models/obs_factory/obs_project.rb'
- 'app/models/obs_factory/openqa_job.rb'
- 'app/models/obs_factory/request.rb'
- 'app/models/obs_factory/staging_project.rb'
- 'app/presenters/obs_factory/obs_project_presenter.rb'
- 'app/presenters/obs_factory/staging_project_presenter.rb'

Expand All @@ -1237,7 +1200,7 @@ Style/RedundantBegin:
- 'db/checker.rb'
- 'script/start_test_backend'

# Offense count: 34
# Offense count: 35
# Cop supports --auto-correct.
# Configuration parameters: AllowMultipleReturnValues.
Style/RedundantReturn:
Expand Down Expand Up @@ -1330,21 +1293,20 @@ Style/UnneededCondition:
- 'app/models/binary_release.rb'
- 'script/import_database.rb'

# Offense count: 235
# Offense count: 242
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, MinSize, WordRegex.
# SupportedStyles: percent, brackets
Style/WordArray:
EnforcedStyle: percent
MinSize: 39
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Style/ZeroLengthPredicate:
Exclude:
- 'app/presenters/obs_factory/staging_project_presenter.rb'

# Offense count: 7659
# Offense count: 7657
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Expand Down
61 changes: 21 additions & 40 deletions src/api/lib/tasks/dev.rake
Original file line number Diff line number Diff line change
Expand Up @@ -78,56 +78,37 @@ namespace :dev do
Rake::Task['db:structure:verify_no_bigint'].invoke
end
namespace :lint do
unless Rails.env.production?
namespace :rubocop do
require 'rubocop/rake_task'
namespace :rubocop do
desc 'Run the ruby linter in rails and in root'
task all: [:root, :rails] do
end

desc 'Run the ruby linter in rails'
task :rails do
sh 'rubocop', '-D', '-F', '-S', '--fail-level', 'convention', '--ignore_parent_exclusion'
end

desc 'Run the ruby linter in rails and in root'
desc 'Run the ruby linter in root'
task :root do
Dir.chdir('../..') do
sh 'rubocop', '-D', '-F', '-S', '--fail-level', 'convention'
end
end

namespace :auto_gen_config do
desc 'Autogenerate rubocop config in rails and in root'
task all: [:root, :rails] do
end

desc 'Run the ruby linter in rails'
desc 'Autogenerate rubocop config in rails'
task :rails do
sh 'rubocop', '-D', '-F', '-S', '--fail-level', 'convention', '--ignore_parent_exclusion'
sh 'rubocop --auto-gen-config --ignore_parent_exclusion || exit 0'
end

desc 'Run the ruby linter in root'
task :root do
Dir.chdir('../..') do
sh 'rubocop', '-D', '-F', '-S', '--fail-level', 'convention'
end
end

namespace :auto_gen_config do
desc 'Autogenerate rubocop config in rails and in root'
task all: [:root, :rails] do
end

desc 'Autogenerate rubocop config in rails'
RuboCop::RakeTask.new(:rails) do |task|
task.options = ['-D', '-F', '-S', '--fail-level', 'convention', '--ignore_parent_exclusion']
end

desc 'Autogenerate rubocop config in root'
task :root do
Dir.chdir('../..') do
Rake::Task['dev:lint:rubocop:rails'].invoke
end
end
namespace :auto_gen_config do
task all: [:root, :rails] do
end
desc 'Autogenerate rubocop config in rails'
RuboCop::RakeTask.new(:rails) do |task|
task.options = ['--auto-gen-config', '--ignore_parent_exclusion']
task.fail_on_error = false
end
desc 'Autogenerate rubocop config in root'
task :root do
Dir.chdir('../..') do
Rake::Task['dev:lint:rubocop:auto_gen_config:rails'].invoke
end
end
sh 'rubocop --auto-gen-config || exit 0'
end
end
end
Expand Down

0 comments on commit c263005

Please sign in to comment.