Skip to content

Commit

Permalink
Merge pull request #117 from chef/level
Browse files Browse the repository at this point in the history
Force the fail level to :convention and set rules to :refactor level
  • Loading branch information
tas50 authored Jul 19, 2019
2 parents 72cc47a + 281a503 commit e047d60
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 16 deletions.
7 changes: 7 additions & 0 deletions bin/cookstyle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), %w(.. lib))

require 'cookstyle'

# force the fail level to :convention so that we can set all our new rules to
# the lowest level of :refactor without failing everyone's CI jobs
unless ARGV.include?('--fail-level')
ARGV << '--fail-level'
ARGV << 'C'
end

if ARGV.size == 1 && %w(-v --version).include?(ARGV.first)
puts "Cookstyle #{Cookstyle::VERSION}"
print ' * RuboCop '
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/chef/attribute_keys.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ def on_send(node)
def on_node_attribute_access(node)
if node.type == :str
style_detected(:strings)
add_offense(node, location: :expression, message: MSG % style, severity: :warning) if style == :symbols
add_offense(node, location: :expression, message: MSG % style, severity: :refactor) if style == :symbols
elsif node.type == :sym
style_detected(:symbols)
add_offense(node, location: :expression, message: MSG % style, severity: :warning) if style == :strings
add_offense(node, location: :expression, message: MSG % style, severity: :refactor) if style == :strings
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/chef/berksfile_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def old_berkshelf_url?(url)

def on_send(node)
berksfile_source?(node) do
add_offense(node, location: :expression, message: MSG, severity: :warning)
add_offense(node, location: :expression, message: MSG, severity: :refactor)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/chef/comment_sentence_spacing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def investigate(processed_source)
return unless processed_source.ast
processed_source.comments.each do |comment|
if comment.text.match?(/(.|\?)\s{2}/) # https://rubular.com/r/8o3SiDrQMJSzuU
add_offense(comment, location: comment.loc.expression, message: MSG, severity: :warning)
add_offense(comment, location: comment.loc.expression, message: MSG, severity: :refactor)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/chef/comments_copyright_format.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def investigate(processed_source)
next unless comment.inline? # headers aren't in blocks

if invalid_copyright_comment?(comment)
add_offense(comment, location: comment.loc.expression, message: MSG, severity: :warning)
add_offense(comment, location: comment.loc.expression, message: MSG, severity: :refactor)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/chef/comments_format.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def investigate(processed_source)
next unless comment.inline? # headers aren't in blocks

if invalid_comment?(comment)
add_offense(comment, location: comment.loc.expression, message: MSG, severity: :warning)
add_offense(comment, location: comment.loc.expression, message: MSG, severity: :refactor)
end
end
end
Expand Down
4 changes: 1 addition & 3 deletions lib/rubocop/cop/chef/file_mode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ class FileMode < Cop

def on_send(node)
resource_mode?(node) do |mode_int|
# for post April 2020
# add_offense(mode_int, location: :expression, message: MSG, severity: octal?(mode_int) ? :warning : :error)
add_offense(mode_int, location: :expression, message: MSG, severity: :warning)
add_offense(mode_int, location: :expression, message: MSG, severity: :refactor)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/chef/insecure_cookbook_url.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def insecure_url?(url)

def on_send(node)
insecure_cb_url?(node) do
add_offense(node, location: :expression, message: MSG, severity: :warning)
add_offense(node, location: :expression, message: MSG, severity: :refactor)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/chef/node_normal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class NodeNormal < Cop

def on_send(node)
node_normal?(node) do
add_offense(node, location: :expression, message: MSG, severity: :warning)
add_offense(node, location: :expression, message: MSG, severity: :refactor)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/chef/node_normal_unless.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class NodeNormalUnless < Cop

def on_send(node)
node_normal_unless?(node) do
add_offense(node, location: :expression, message: MSG, severity: :warning)
add_offense(node, location: :expression, message: MSG, severity: :refactor)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/chef/node_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class NodeSet < Cop

def on_send(node)
node_set?(node) do
add_offense(node, location: :expression, message: MSG, severity: :warning)
add_offense(node, location: :expression, message: MSG, severity: :refactor)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/chef/node_set_unless.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class NodeSetUnless < Cop

def on_send(node)
node_set_unless?(node) do
add_offense(node, location: :expression, message: MSG, severity: :warning)
add_offense(node, location: :expression, message: MSG, severity: :refactor)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/chef/service_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ServiceResource < Cop
def on_send(node)
execute_command?(node) do |command|
if starts_service?(command)
add_offense(command, location: :expression, message: MSG, severity: :warning)
add_offense(command, location: :expression, message: MSG, severity: :refactor)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/chef/tmp_path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class TmpPath < Cop
def on_send(node)
remote_file?(node) do |command|
if hardcoded_tmp?(command) && !file_cache_path?(command)
add_offense(command, location: :expression, message: MSG, severity: :warning)
add_offense(command, location: :expression, message: MSG, severity: :refactor)
end
end
end
Expand Down

0 comments on commit e047d60

Please sign in to comment.