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 all the things #36

Open
solarce opened this issue Mar 2, 2015 · 1 comment
Open

Rubocop all the things #36

solarce opened this issue Mar 2, 2015 · 1 comment

Comments

@solarce
Copy link
Contributor

solarce commented Mar 2, 2015

Start work on adding https://github.com/bbatsov/rubocop#installation to the CI runs and reducing the amount of errors and warnings from Rubocop.

Ruby Style Guide is love. RSG is life.

@solarce
Copy link
Contributor Author

solarce commented Mar 2, 2015

Current output from a stock rubocop run

127 solarce@malachi ~/code/knife-block/knife-block (git)-[adding-rubocop] % be rubocop                                                                                            :(
warning: parser/current is loading parser/ruby21, which recognizes
warning: 2.1.5-compliant syntax, but you are running 2.1.4.
Inspecting 7 files
C.CWCCW

Offenses:

knife-block.gemspec:5:24: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  gem.authors       = ["proffalken"]
                       ^^^^^^^^^^^^
knife-block.gemspec:6:24: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  gem.email         = ["theprofessor@threedrunkensysadsonthe.net"]
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
knife-block.gemspec:7:23: C: %q-literals should be delimited by ( and )
  gem.description   = %q{Create and manage knife.rb files for OpsCodes' Chef}
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
knife-block.gemspec:7:23: C: Use %q only for strings that contain both single quotes and double quotes.
  gem.description   = %q{Create and manage knife.rb files for OpsCodes' Chef}
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
knife-block.gemspec:8:23: C: %q-literals should be delimited by ( and )
knife-block.gemspec:16:24: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  gem.require_paths = ["lib"]
                       ^^^^^
Rakefile:2:9: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
require "bundler/gem_tasks"
        ^^^^^^^^^^^^^^^^^^^
Rakefile:6:6: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
desc "Run rubocop"
     ^^^^^^^^^^^^^
Rakefile:8:8: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  puts "Running Rubocop checks"
       ^^^^^^^^^^^^^^^^^^^^^^^^
Rakefile:10:8: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  puts "Rubocop Finished"
       ^^^^^^^^^^^^^^^^^^
Rakefile:11:8: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  puts "==============="
       ^^^^^^^^^^^^^^^^^
Rakefile:14:6: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
desc "Run Unit Tests"
     ^^^^^^^^^^^^^^^^
Rakefile:15:6: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
puts "Running Unit Tests"
     ^^^^^^^^^^^^^^^^^^^^
Rakefile:16:20: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
Rake::TestTask.new("default") do |t|
                   ^^^^^^^^^
Rakefile:17:1: C: Use 2 (not 4) spaces for indentation.
    t.pattern = "test/unit/*_test.rb"
^^^^
Rakefile:17:17: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
    t.pattern = "test/unit/*_test.rb"
                ^^^^^^^^^^^^^^^^^^^^^
Rakefile:20:1: C: Inconsistent indentation detected.
puts "Unit Tests finished"
^^^^^^^^^^^^^^^^^^^^^^^^^^
Rakefile:20:6: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
puts "Unit Tests finished"
     ^^^^^^^^^^^^^^^^^^^^^
Rakefile:21:1: C: Inconsistent indentation detected.
puts "==================="
^^^^^^^^^^^^^^^^^^^^^^^^^^
Rakefile:21:6: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
puts "==================="
     ^^^^^^^^^^^^^^^^^^^^^
lib/chef/knife/block.rb:2:81: C: Line is too long. [83/80]
# to allow interaction with multiple knife servers in an easy and consistent manner
                                                                                ^^^
lib/chef/knife/block.rb:12:3: C: Missing top-level class documentation comment.
  class Knife
  ^^^^^
lib/chef/knife/block.rb:13:5: C: Assignment Branch Condition size for get_config_file is too high. [19.26/15]
    def get_config_file
    ^^^
lib/chef/knife/block.rb:13:9: C: Do not prefix reader method names with get_.
    def get_config_file
        ^^^^^^^^^^^^^^^
lib/chef/knife/block.rb:23:81: C: Line is too long. [100/80]
      # if we haven't created our knife.rb yet, set defaults to ~/.chef so we can create the config.
                                                                                ^^^^^^^^^^^^^^^^^^^^
lib/chef/knife/block.rb:24:81: C: Line is too long. [97/80]
      config[:config_file] ? File.dirname(config[:config_file]) : File.join(ENV['HOME'], '.chef')
                                                                                ^^^^^^^^^^^^^^^^^
lib/chef/knife/block.rb:29:1: C: Missing top-level module documentation comment.
module GreenAndSecure
^^^^^^
lib/chef/knife/block.rb:30:3: C: Replace class var @@current_chef_version with a class instance var.
  @@current_chef_version = ::Gem::Version.new(::Chef::VERSION)
  ^^^^^^^^^^^^^^^^^^^^^^
lib/chef/knife/block.rb:31:3: C: Replace class var @@knife with a class instance var.
  @@knife = ::Chef::Knife.new
  ^^^^^^^
lib/chef/knife/block.rb:45:3: C: Assignment Branch Condition size for locate_config_file is too high. [20.71/15]
  def locate_config_file(config)
  ^^^
lib/chef/knife/block.rb:45:3: C: Method has too many lines. [20/10]
  def locate_config_file(config)
  ^^^
lib/chef/knife/block.rb:48:81: C: Line is too long. [82/80]
    # Look for $KNIFE_HOME/knife.rb (allow multiple knives config on same machine)
                                                                                ^^
lib/chef/knife/block.rb:53:5: C: Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
    if Dir.pwd
    ^^
lib/chef/knife/block.rb:75:26: C: Do not use :: for method calls.
    base = GreenAndSecure::chef_config_base
                         ^^
lib/chef/knife/block.rb:76:5: C: Use a guard clause instead of wrapping the code inside a conditional expression.
    if File.exists?(base+"/knife.rb") then
    ^^
lib/chef/knife/block.rb:76:13: W: File.exists? is deprecated in favor of File.exist?.
    if File.exists?(base+"/knife.rb") then
            ^^^^^^^
lib/chef/knife/block.rb:76:25: C: Surrounding space missing for operator '+'.
    if File.exists?(base+"/knife.rb") then
                        ^
lib/chef/knife/block.rb:76:26: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
    if File.exists?(base+"/knife.rb") then
                         ^^^^^^^^^^^
lib/chef/knife/block.rb:76:39: C: Do not use then for multi-line if.
    if File.exists?(base+"/knife.rb") then
                                      ^^^^
lib/chef/knife/block.rb:77:32: C: Surrounding space missing for operator '+'.
      unless File.symlink?(base+"/knife.rb")
                               ^
lib/chef/knife/block.rb:77:33: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
      unless File.symlink?(base+"/knife.rb")
                                ^^^^^^^^^^^
lib/chef/knife/block.rb:79:81: C: Line is too long. [93/80]
        puts "Please copy the file to #{base}/knife-<servername>.rb and re-run this command."
                                                                                ^^^^^^^^^^^^^
lib/chef/knife/block.rb:86:34: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
    File.basename(server_config, ".rb").split('-')[1 .. -1].join('-')
                                 ^^^^^
lib/chef/knife/block.rb:86:52: C: Space inside range literal.
    File.basename(server_config, ".rb").split('-')[1 .. -1].join('-')
                                                   ^^^^^^^
lib/chef/knife/block.rb:91:81: C: Line is too long. [81/80]
    @berkshelf_path ||= ENV['BERKSHELF_PATH'] || File.expand_path('~/.berkshelf')
                                                                                ^
lib/chef/knife/block.rb:94:3: C: Use module_function instead of extend self.
  extend self
  ^^^^^^^^^^^
lib/chef/knife/block.rb:96:3: C: Missing top-level class documentation comment.
  class Block < Chef::Knife
  class BlockList < Chef::Knife
  ^^^^^
lib/chef/knife/block.rb:116:1: C: Extra empty line detected at class body beginning.
lib/chef/knife/block.rb:117:12: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
    banner "knife block list"
           ^^^^^^^^^^^^^^^^^^
lib/chef/knife/block.rb:122:21: C: Do not use :: for method calls.
      GreenAndSecure::check_block_setup
                    ^^
lib/chef/knife/block.rb:124:35: W: File.exists? is deprecated in favor of File.exist?.
      @current_server ||= if File.exists?(GreenAndSecure::chef_config_base+"/knife.rb") then
                                  ^^^^^^^
lib/chef/knife/block.rb:124:57: C: Do not use :: for method calls.
      @current_server ||= if File.exists?(GreenAndSecure::chef_config_base+"/knife.rb") then
                                                        ^^
lib/chef/knife/block.rb:124:75: C: Surrounding space missing for operator '+'.
      @current_server ||= if File.exists?(GreenAndSecure::chef_config_base+"/knife.rb") then
                                                                          ^
lib/chef/knife/block.rb:124:76: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
      @current_server ||= if File.exists?(GreenAndSecure::chef_config_base+"/knife.rb") then
                                                                           ^^^^^^^^^^^
lib/chef/knife/block.rb:124:81: C: Line is too long. [92/80]
      @current_server ||= if File.exists?(GreenAndSecure::chef_config_base+"/knife.rb") then
                                                                                ^^^^^^^^^^^^
lib/chef/knife/block.rb:124:89: C: Do not use then for multi-line if.
      @current_server ||= if File.exists?(GreenAndSecure::chef_config_base+"/knife.rb") then
                                                                                        ^^^^
lib/chef/knife/block.rb:125:43: C: Do not use :: for method calls.
                            GreenAndSecure::printable_server(File.readlink(GreenAndSecure::chef_config_base+"/knife.rb"))
                                          ^^
lib/chef/knife/block.rb:125:81: C: Line is too long. [121/80]
                            GreenAndSecure::printable_server(File.readlink(GreenAndSecure::chef_config_base+"/knife.rb"))
                                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/chef/knife/block.rb:125:90: C: Do not use :: for method calls.
                            GreenAndSecure::printable_server(File.readlink(GreenAndSecure::chef_config_base+"/knife.rb"))
                                                                                         ^^
lib/chef/knife/block.rb:125:108: C: Surrounding space missing for operator '+'.
                            GreenAndSecure::printable_server(File.readlink(GreenAndSecure::chef_config_base+"/knife.rb"))
                                                                                                           ^
lib/chef/knife/block.rb:125:109: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
                            GreenAndSecure::printable_server(File.readlink(GreenAndSecure::chef_config_base+"/knife.rb"))
                                                                                                            ^^^^^^^^^^^
lib/chef/knife/block.rb:126:27: C: Redundant empty else-clause.
                          else
                          ^^^^
lib/chef/knife/block.rb:134:81: C: Line is too long. [87/80]
      ## get the list of available environments by searching ~/.chef for knife.rb files
                                                                                ^^^^^^^
lib/chef/knife/block.rb:135:43: C: Do not use :: for method calls.
      @servers ||= Dir.glob(GreenAndSecure::chef_config_base+"/knife-*.rb").sort.map do |fn|
                                          ^^
lib/chef/knife/block.rb:135:61: C: Surrounding space missing for operator '+'.
      @servers ||= Dir.glob(GreenAndSecure::chef_config_base+"/knife-*.rb").sort.map do |fn|
                                                            ^
lib/chef/knife/block.rb:135:62: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
      @servers ||= Dir.glob(GreenAndSecure::chef_config_base+"/knife-*.rb").sort.map do |fn|
                                                             ^^^^^^^^^^^^^
lib/chef/knife/block.rb:135:81: C: Line is too long. [92/80]
      @servers ||= Dir.glob(GreenAndSecure::chef_config_base+"/knife-*.rb").sort.map do |fn|
                                                                                ^^^^^^^^^^^^
lib/chef/knife/block.rb:136:23: C: Do not use :: for method calls.
        GreenAndSecure::printable_server(fn)
                      ^^
lib/chef/knife/block.rb:142:21: C: Do not use :: for method calls.
      GreenAndSecure::check_block_setup
                    ^^
lib/chef/knife/block.rb:143:12: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
      puts "The available chef servers are:"
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/chef/knife/block.rb:145:37: C: Do not use then for multi-line if.
        if server == current_server then
                                    ^^^^
lib/chef/knife/block.rb:154:3: C: Missing top-level class documentation comment.
  class BlockUse < Chef::Knife
  ^^^^^
lib/chef/knife/block.rb:155:1: C: Extra empty line detected at class body beginning.
lib/chef/knife/block.rb:156:12: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
    banner "knife block use SERVERNAME"
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/chef/knife/block.rb:158:5: C: Assignment Branch Condition size for run is too high. [32.94/15]
    def run
    ^^^
lib/chef/knife/block.rb:158:5: C: Method has too many lines. [29/10]
    def run
    ^^^
lib/chef/knife/block.rb:158:5: C: Perceived complexity for run is too high. [8/7]
    def run
    ^^^
lib/chef/knife/block.rb:160:14: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
        puts "Please specify a server"
             ^^^^^^^^^^^^^^^^^^^^^^^^^
lib/chef/knife/block.rb:166:7: W: Useless assignment to variable - list.
      list = GreenAndSecure::BlockList.new
      ^^^^
lib/chef/knife/block.rb:169:28: C: Do not use :: for method calls.
      base = GreenAndSecure::chef_config_base
                           ^^
lib/chef/knife/block.rb:171:15: W: File.exists? is deprecated in favor of File.exist?.
      if File.exists?(base+"/knife-#{new_server}.rb")
              ^^^^^^^
lib/chef/knife/block.rb:171:27: C: Surrounding space missing for operator '+'.
      if File.exists?(base+"/knife-#{new_server}.rb")
                          ^
lib/chef/knife/block.rb:173:9: C: Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
        if File.exists?(base+"/knife.rb")
        ^^
lib/chef/knife/block.rb:173:17: W: File.exists? is deprecated in favor of File.exist?.
        if File.exists?(base+"/knife.rb")
                ^^^^^^^
lib/chef/knife/block.rb:173:29: C: Surrounding space missing for operator '+'.
        if File.exists?(base+"/knife.rb")
                            ^
lib/chef/knife/block.rb:173:30: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
        if File.exists?(base+"/knife.rb")
                             ^^^^^^^^^^^
lib/chef/knife/block.rb:174:27: C: Surrounding space missing for operator '+'.
          File.unlink(base+"/knife.rb")
                          ^
lib/chef/knife/block.rb:174:28: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
          File.unlink(base+"/knife.rb")
                           ^^^^^^^^^^^
lib/chef/knife/block.rb:177:26: C: Surrounding space missing for operator '+'.
        File.symlink(base+"/knife-#{new_server}.rb", base+"/knife.rb")
                         ^
lib/chef/knife/block.rb:177:58: C: Surrounding space missing for operator '+'.
    if ENV['TRAVIS']
    ^^
test/unit/knifeblock_test.rb:21:48: W: File.exists? is deprecated in favor of File.exist?.
      FileUtils.mkpath(@chef_path) unless File.exists?(@chef_path)
                                               ^^^^^^^
test/unit/knifeblock_test.rb:22:51: W: File.exists? is deprecated in favor of File.exist?.
      FileUtils.touch("#{@knife_ci}") unless File.exists?("#{@knife_ci}")
                                                  ^^^^^^^
test/unit/knifeblock_test.rb:23:36: C: Space missing after comma.
      FileUtils.ln_s("#{@knife_ci}","#{@chef_path}/knife.rb") unless File.exists?("#{@chef_path}/knife.rb")
                                   ^
test/unit/knifeblock_test.rb:23:75: W: File.exists? is deprecated in favor of File.exist?.
      FileUtils.ln_s("#{@knife_ci}","#{@chef_path}/knife.rb") unless File.exists?("#{@chef_path}/knife.rb")
                                                                          ^^^^^^^
test/unit/knifeblock_test.rb:23:81: C: Line is too long. [107/80]
      FileUtils.ln_s("#{@knife_ci}","#{@chef_path}/knife.rb") unless File.exists?("#{@chef_path}/knife.rb")
                                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
test/unit/knifeblock_test.rb:28:5: C: Use a guard clause instead of wrapping the code inside a conditional expression.
    if ENV['TRAVIS']
    ^^
test/unit/knifeblock_test.rb:29:49: W: Useless assignment to variable - force.
      FileUtils.remove_entry_secure(@chef_path, force = true) if File.exists?(@chef_path)
                                                ^^^^^
test/unit/knifeblock_test.rb:29:71: W: File.exists? is deprecated in favor of File.exist?.
      FileUtils.remove_entry_secure(@chef_path, force = true) if File.exists?(@chef_path)
                                                                      ^^^^^^^
test/unit/knifeblock_test.rb:29:81: C: Line is too long. [89/80]
      FileUtils.remove_entry_secure(@chef_path, force = true) if File.exists?(@chef_path)
                                                                                ^^^^^^^^^
test/unit/knifeblock_test.rb:34:33: C: Space missing after comma.
    assert_match(/\d+\.\d+\.\d+/,@green.current_chef_version.to_s, "FAIL: Chef version undetected!")
                                ^
test/unit/knifeblock_test.rb:34:68: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
    assert_match(/\d+\.\d+\.\d+/,@green.current_chef_version.to_s, "FAIL: Chef version undetected!")
                                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test/unit/knifeblock_test.rb:34:81: C: Line is too long. [100/80]
    assert_match(/\d+\.\d+\.\d+/,@green.current_chef_version.to_s, "FAIL: Chef version undetected!")
                                                                                ^^^^^^^^^^^^^^^^^^^^
test/unit/knifeblock_test.rb:38:18: C: Use %r for regular expressions matching more than 1 '/' character.
    assert_match(/.*\/.chef\/knife\.rb/,@green.chef_config_base+"/knife.rb", "FAIL: knife.rb not found!")
                 ^^^^^^^^^^^^^^^^^^^^^^
test/unit/knifeblock_test.rb:38:40: C: Space missing after comma.
    assert_match(/.*\/.chef\/knife\.rb/,@green.chef_config_base+"/knife.rb", "FAIL: knife.rb not found!")
                                       ^
test/unit/knifeblock_test.rb:38:64: C: Surrounding space missing for operator '+'.
    assert_match(/.*\/.chef\/knife\.rb/,@green.chef_config_base+"/knife.rb", "FAIL: knife.rb not found!")
                                                               ^
test/unit/knifeblock_test.rb:38:65: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
    assert_match(/.*\/.chef\/knife\.rb/,@green.chef_config_base+"/knife.rb", "FAIL: knife.rb not found!")
                                                                ^^^^^^^^^^^
test/unit/knifeblock_test.rb:38:78: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
    assert_match(/.*\/.chef\/knife\.rb/,@green.chef_config_base+"/knife.rb", "FAIL: knife.rb not found!")
                                                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
test/unit/knifeblock_test.rb:38:81: C: Line is too long. [105/80]
    assert_match(/.*\/.chef\/knife\.rb/,@green.chef_config_base+"/knife.rb", "FAIL: knife.rb not found!")
                                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^
test/unit/knifeblock_test.rb:42:36: C: Surrounding space missing for operator '+'.
    assert(File.symlink?(@chef_path+"/knife.rb"), "knife.rb was not a symlink, please link it to #{@chef_path}/knife-<servername>.rb")
                                   ^
test/unit/knifeblock_test.rb:42:37: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
    assert(File.symlink?(@chef_path+"/knife.rb"), "knife.rb was not a symlink, please link it to #{@chef_path}/knife-<servername>.rb")
                                    ^^^^^^^^^^^
test/unit/knifeblock_test.rb:42:81: C: Line is too long. [134/80]
    assert(File.symlink?(@chef_path+"/knife.rb"), "knife.rb was not a symlink, please link it to #{@chef_path}/knife-<servername>.rb")
                                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

7 files inspected, 167 offenses detected
1 solarce@malachi ~/code/knife-block/knife-block (git)-[adding-rubocop] %

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant