Skip to content

Commit

Permalink
Merge pull request #102 from chef/more_cops
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Smith <tsmith@chef.io>
  • Loading branch information
tas50 authored Sep 17, 2020
2 parents 1fe8123 + a2ac654 commit 1f200d4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bin/chefstyle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), %w{.. lib})
$LOAD_PATH.unshift File.join(__dir__, %w{.. lib})

require "chefstyle"

Expand Down
2 changes: 1 addition & 1 deletion chefstyle.gemspec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true
lib = File.expand_path("../lib", __FILE__)
lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "chefstyle/version"

Expand Down
28 changes: 28 additions & 0 deletions config/chefstyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,34 @@ Lint/DeprecatedOpenSSLConstant:
Lint/Syntax:
Enabled: true

# remove extra requires like 'thread'
Lint/RedundantRequireStatement:
Enabled: true

# simplify stripping strings
Style/Strip:
Enabled: true

# simplify getting min/max
Style/RedundantSort:
Enabled: true

# no need for .rb in requires
Style/RedundantFileExtensionInRequire:
Enabled: true

# more code you don't need
Style/RedundantCondition:
Enabled: true

# Use __dir__ to simplify things
Style/Dir:
Enabled: true

# Use __FILE__ or __dir__ to simplify expand_paths
Style/ExpandPathArguments:
Enabled: true

ChefRuby/Ruby27KeywordArgumentWarnings:
Description: Pass options to shell_out helpers without the brackets to avoid Ruby 2.7 deprecation warnings.
Enabled: true
Expand Down
4 changes: 2 additions & 2 deletions lib/chefstyle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module RuboCop
class ConfigLoader
RUBOCOP_HOME.gsub!(
/^.*$/,
File.realpath(File.join(File.dirname(__FILE__), ".."))
File.realpath(File.join(__dir__, ".."))
)

DEFAULT_FILE.gsub!(
Expand All @@ -31,7 +31,7 @@ def self.config
require_relative "rubocop/chef"

# Chef custom cops
Dir.glob(File.dirname(__FILE__) + "/rubocop/cop/chef/**/*.rb") do |file|
Dir.glob(__dir__ + "/rubocop/cop/chef/**/*.rb") do |file|
next if File.directory?(file)

require_relative file # not actually relative but require_relative is faster
Expand Down

0 comments on commit 1f200d4

Please sign in to comment.