Skip to content

Commit

Permalink
Merge pull request #337 from rock-core/rubocop
Browse files Browse the repository at this point in the history
chore: fix rubocop and enable/disable new cops
  • Loading branch information
doudou committed Oct 19, 2021
2 parents 0811b90 + 886d786 commit cc7eaba
Show file tree
Hide file tree
Showing 44 changed files with 413 additions and 275 deletions.
77 changes: 77 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,80 @@ Metrics/ParameterLists:

Naming/MethodParameterName:
AllowedNames: [io, id, to, by, on, in, at, ip, db, ws]

Gemspec/DateAssignment: # new in 1.10
Enabled: true
Layout/LineEndStringConcatenationIndentation: # new in 1.18
Enabled: true
Layout/SpaceBeforeBrackets: # new in 1.7
Enabled: true
Lint/AmbiguousAssignment: # new in 1.7
Enabled: true
Lint/AmbiguousOperatorPrecedence: # new in 1.21
Enabled: true
Lint/AmbiguousRange: # new in 1.19
Enabled: true
Lint/DeprecatedConstants: # new in 1.8
Enabled: true
Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
Enabled: true
Lint/EmptyClass: # new in 1.3
Enabled: true
Lint/EmptyInPattern: # new in 1.16
Enabled: true
Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
Enabled: true
Lint/LambdaWithoutLiteralBlock: # new in 1.8
Enabled: true
Lint/NumberedParameterAssignment: # new in 1.9
Enabled: true
Lint/OrAssignmentToConstant: # new in 1.9
Enabled: true
Lint/RedundantDirGlobSort: # new in 1.8
Enabled: true
Lint/RequireRelativeSelfPath: # new in 1.22
Enabled: true
Lint/SymbolConversion: # new in 1.9
Enabled: true
Lint/ToEnumArguments: # new in 1.1
Enabled: true
Lint/TripleQuotes: # new in 1.9
Enabled: true
Lint/UnexpectedBlockArity: # new in 1.5
Enabled: true
Lint/UnmodifiedReduceAccumulator: # new in 1.1
Enabled: true
Security/IoMethods: # new in 1.22
Enabled: true
Style/ArgumentsForwarding: # new in 1.1
Enabled: true
Style/CollectionCompact: # new in 1.2
Enabled: true
Style/DocumentDynamicEvalDefinition: # new in 1.1
Enabled: true
Style/EndlessMethod: # new in 1.8
Enabled: true
Style/HashExcept: # new in 1.7
Enabled: true
Style/IfWithBooleanLiteralBranches: # new in 1.9
Enabled: true
Style/InPatternThen: # new in 1.16
Enabled: true
Style/MultilineInPatternThen: # new in 1.16
Enabled: true
Style/NegatedIfElseCondition: # new in 1.2
Enabled: true
Style/NilLambda: # new in 1.3
Enabled: true
Style/NumberedParameters: # new in 1.22
Enabled: true
Style/NumberedParametersLimit: # new in 1.22
Enabled: true
Style/QuotedSymbols: # new in 1.16
Enabled: true
Style/RedundantSelfAssignmentBranch: # new in 1.19
Enabled: true
Style/StringChars: # new in 1.12
Enabled: true
Style/SwapValues: # new in 1.1
Enabled: true
13 changes: 13 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

Lint/NoReturnInBeginEndBlocks: # new in 1.2
Enabled: false
Style/RedundantArgument: # new in 1.4
Enabled: false
Style/HashConversion: # new in 1.10
Enabled: false
Style/SelectByRegexp: # new in 1.22
Enabled: false
Lint/EmptyBlock: # new in 1.1
Enabled: false
Lint/DuplicateBranch: # new in 1.3
Enabled: false

# Offense count: 25
# Cop supports --auto-correct.
Layout/HeredocIndentation:
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ task "helpers" do
completion = shell[1].new(cli[0], command: cli[1])
completion_file = File.join(completion_dir, "#{cli[0]}_#{shell[0]}")

IO.write(completion_file, completion.generate)
File.write(completion_file, completion.generate)
end
erb = File.read(File.join(templates_dir, "helpers.#{shell[0]}.erb"))
helper_file = File.join(shell_dir, "autoproj_#{shell[0]}")

IO.write(helper_file, ::ERB.new(erb, nil, "-").result(binding))
File.write(helper_file, ::ERB.new(erb, nil, "-").result(binding))
end
end

Expand Down
51 changes: 27 additions & 24 deletions bin/autoproj_bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ module Autoproj

if config["ruby_executable"] != Gem.ruby
raise "this autoproj installation was already bootstrapped using "\
"#{config['ruby_executable']}, but you are currently running "\
"under #{Gem.ruby}. Changing the ruby interpreter in a given "\
"workspace is not supported, you need to do a clean bootstrap"
"#{config['ruby_executable']}, but you are currently running "\
"under #{Gem.ruby}. Changing the ruby interpreter in a given "\
"workspace is not supported, you need to do a clean bootstrap"
end
@ruby_executable = config["ruby_executable"]
@local = false
Expand Down Expand Up @@ -254,7 +254,7 @@ module Autoproj
end
end
raise ArgumentError, "cannot find a gem program "\
"(tried #{candidates.sort.join(', ')} in #{ruby_bindir})"
"(tried #{candidates.sort.join(', ')} in #{ruby_bindir})"
end

# The content of the default {#gemfile}
Expand Down Expand Up @@ -286,28 +286,28 @@ module Autoproj
@autoproj_options << "--debug"
end
opt.on "--gem-source=URL", String, "use this source for RubyGems "\
"instead of rubygems.org" do |url|
"instead of rubygems.org" do |url|
@gem_source = url
end
opt.on "--gems-path=PATH", "install gems under this path instead "\
"of ~/.autoproj/gems" do |path|
"of ~/.autoproj/gems" do |path|
self.gems_install_path = path
end
opt.on "--public-gems", "install gems in the default gem location" do
install_gems_in_gem_user_dir
end
opt.on "--bundler-version=VERSION_CONSTRAINT", String, "use the provided "\
"string as a version constraint for bundler" do |version|
"string as a version constraint for bundler" do |version|
@config["bundler_version"] = version
end
opt.on "--version=VERSION_CONSTRAINT", String, "use the provided "\
"string as a version constraint for autoproj" do |version|
"string as a version constraint for autoproj" do |version|
raise "cannot give both --version and --gemfile" if @gemfile

@gemfile = default_gemfile_contents(version)
end
opt.on "--gemfile=PATH", String, "use the given Gemfile to install "\
"autoproj instead of the default" do |path|
"autoproj instead of the default" do |path|
raise "cannot give both --version and --gemfile" if @gemfile

@gemfile = File.read(path)
Expand All @@ -318,30 +318,33 @@ module Autoproj
@config.clear
end
opt.on "--seed-config=PATH", String, "path to a seed file that "\
"should be used to initialize the configuration" do |path|
"should be used to initialize the configuration" do |path|
add_seed_config(path)
end
opt.on "--prefer-os-independent-packages", "prefer OS-independent "\
"packages (such as a RubyGem) over their OS-packaged equivalent "\
"(e.g. the thor gem vs. the ruby-thor debian package)" do
"packages (such as a RubyGem) over their OS-packaged equivalent "\
"(e.g. the thor gem vs. the ruby-thor debian package)" do
@prefer_indep_over_os_packages = true
end
opt.on "--[no-]color", "do not use colored output (enabled by "\
"default if the terminal supports it)" do |color|
"default if the terminal supports it)" do |color|
if color then @autoproj_options << "--color"
else @autoproj_options << "--no-color"
else
@autoproj_options << "--no-color"
end
end
opt.on "--[no-]progress", "do not use progress output (enabled by "\
"default if the terminal supports it)" do |progress|
"default if the terminal supports it)" do |progress|
if progress then @autoproj_options << "--progress"
else @autoproj_options << "--no-progress"
else
@autoproj_options << "--no-progress"
end
end
opt.on "--[no-]interactive", "if non-interactive, use default "\
"answer for questions" do |flag|
"answer for questions" do |flag|
if flag then @autoproj_options << "--interactive"
else @autoproj_options << "--no-interactive"
else
@autoproj_options << "--no-interactive"
end
end
end
Expand Down Expand Up @@ -425,7 +428,7 @@ module Autoproj
bundler_path
else
STDERR.puts "gem install bundler returned successfully, but still "\
"cannot find bundler in #{gems_gem_home}"
"cannot find bundler in #{gems_gem_home}"
nil
end
end
Expand Down Expand Up @@ -722,9 +725,9 @@ require 'bundler/setup'
if (current = config["ruby_executable"]) # When upgrading or reinstalling
if current != ruby_executable
raise "this workspace has already been initialized using "\
"#{current}, you cannot run autoproj install with "\
"#{ruby_executable}. If you know what you're doing, "\
"delete the ruby_executable line in config.yml and try again"
"#{current}, you cannot run autoproj install with "\
"#{ruby_executable}. If you know what you're doing, "\
"delete the ruby_executable line in config.yml and try again"
end
else
config["ruby_executable"] = ruby_executable
Expand Down Expand Up @@ -784,15 +787,15 @@ require 'bundler/setup'
puts "running 'autoproj envsh' to generate a proper env.sh"
unless system(Gem.ruby, autoproj_path, "envsh", *@autoproj_options)
STDERR.puts "failed to run autoproj envsh on the newly installed "\
"autoproj (#{autoproj_path})"
"autoproj (#{autoproj_path})"
exit 1
end
# This is really needed on an existing install to install the
# gems that were present in the v1 layout
puts "running 'autoproj osdeps' to re-install missing gems"
unless system(Gem.ruby, autoproj_path, "osdeps", *@autoproj_options)
STDERR.puts "failed to run autoproj osdeps on the newly installed "\
"autoproj (#{autoproj_path})"
"autoproj (#{autoproj_path})"
exit 1
end
end
Expand Down
51 changes: 27 additions & 24 deletions bin/autoproj_install
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ module Autoproj

if config["ruby_executable"] != Gem.ruby
raise "this autoproj installation was already bootstrapped using "\
"#{config['ruby_executable']}, but you are currently running "\
"under #{Gem.ruby}. Changing the ruby interpreter in a given "\
"workspace is not supported, you need to do a clean bootstrap"
"#{config['ruby_executable']}, but you are currently running "\
"under #{Gem.ruby}. Changing the ruby interpreter in a given "\
"workspace is not supported, you need to do a clean bootstrap"
end
@ruby_executable = config["ruby_executable"]
@local = false
Expand Down Expand Up @@ -254,7 +254,7 @@ module Autoproj
end
end
raise ArgumentError, "cannot find a gem program "\
"(tried #{candidates.sort.join(', ')} in #{ruby_bindir})"
"(tried #{candidates.sort.join(', ')} in #{ruby_bindir})"
end

# The content of the default {#gemfile}
Expand Down Expand Up @@ -286,28 +286,28 @@ module Autoproj
@autoproj_options << "--debug"
end
opt.on "--gem-source=URL", String, "use this source for RubyGems "\
"instead of rubygems.org" do |url|
"instead of rubygems.org" do |url|
@gem_source = url
end
opt.on "--gems-path=PATH", "install gems under this path instead "\
"of ~/.autoproj/gems" do |path|
"of ~/.autoproj/gems" do |path|
self.gems_install_path = path
end
opt.on "--public-gems", "install gems in the default gem location" do
install_gems_in_gem_user_dir
end
opt.on "--bundler-version=VERSION_CONSTRAINT", String, "use the provided "\
"string as a version constraint for bundler" do |version|
"string as a version constraint for bundler" do |version|
@config["bundler_version"] = version
end
opt.on "--version=VERSION_CONSTRAINT", String, "use the provided "\
"string as a version constraint for autoproj" do |version|
"string as a version constraint for autoproj" do |version|
raise "cannot give both --version and --gemfile" if @gemfile

@gemfile = default_gemfile_contents(version)
end
opt.on "--gemfile=PATH", String, "use the given Gemfile to install "\
"autoproj instead of the default" do |path|
"autoproj instead of the default" do |path|
raise "cannot give both --version and --gemfile" if @gemfile

@gemfile = File.read(path)
Expand All @@ -318,30 +318,33 @@ module Autoproj
@config.clear
end
opt.on "--seed-config=PATH", String, "path to a seed file that "\
"should be used to initialize the configuration" do |path|
"should be used to initialize the configuration" do |path|
add_seed_config(path)
end
opt.on "--prefer-os-independent-packages", "prefer OS-independent "\
"packages (such as a RubyGem) over their OS-packaged equivalent "\
"(e.g. the thor gem vs. the ruby-thor debian package)" do
"packages (such as a RubyGem) over their OS-packaged equivalent "\
"(e.g. the thor gem vs. the ruby-thor debian package)" do
@prefer_indep_over_os_packages = true
end
opt.on "--[no-]color", "do not use colored output (enabled by "\
"default if the terminal supports it)" do |color|
"default if the terminal supports it)" do |color|
if color then @autoproj_options << "--color"
else @autoproj_options << "--no-color"
else
@autoproj_options << "--no-color"
end
end
opt.on "--[no-]progress", "do not use progress output (enabled by "\
"default if the terminal supports it)" do |progress|
"default if the terminal supports it)" do |progress|
if progress then @autoproj_options << "--progress"
else @autoproj_options << "--no-progress"
else
@autoproj_options << "--no-progress"
end
end
opt.on "--[no-]interactive", "if non-interactive, use default "\
"answer for questions" do |flag|
"answer for questions" do |flag|
if flag then @autoproj_options << "--interactive"
else @autoproj_options << "--no-interactive"
else
@autoproj_options << "--no-interactive"
end
end
end
Expand Down Expand Up @@ -425,7 +428,7 @@ module Autoproj
bundler_path
else
STDERR.puts "gem install bundler returned successfully, but still "\
"cannot find bundler in #{gems_gem_home}"
"cannot find bundler in #{gems_gem_home}"
nil
end
end
Expand Down Expand Up @@ -722,9 +725,9 @@ require 'bundler/setup'
if (current = config["ruby_executable"]) # When upgrading or reinstalling
if current != ruby_executable
raise "this workspace has already been initialized using "\
"#{current}, you cannot run autoproj install with "\
"#{ruby_executable}. If you know what you're doing, "\
"delete the ruby_executable line in config.yml and try again"
"#{current}, you cannot run autoproj install with "\
"#{ruby_executable}. If you know what you're doing, "\
"delete the ruby_executable line in config.yml and try again"
end
else
config["ruby_executable"] = ruby_executable
Expand Down Expand Up @@ -784,15 +787,15 @@ require 'bundler/setup'
puts "running 'autoproj envsh' to generate a proper env.sh"
unless system(Gem.ruby, autoproj_path, "envsh", *@autoproj_options)
STDERR.puts "failed to run autoproj envsh on the newly installed "\
"autoproj (#{autoproj_path})"
"autoproj (#{autoproj_path})"
exit 1
end
# This is really needed on an existing install to install the
# gems that were present in the v1 layout
puts "running 'autoproj osdeps' to re-install missing gems"
unless system(Gem.ruby, autoproj_path, "osdeps", *@autoproj_options)
STDERR.puts "failed to run autoproj osdeps on the newly installed "\
"autoproj (#{autoproj_path})"
"autoproj (#{autoproj_path})"
exit 1
end
end
Expand Down
Loading

0 comments on commit cc7eaba

Please sign in to comment.