Class: RuboCop::Cop::Chef::Correctness::OctalModeAsString

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/chef/correctness/octal_mode_as_string.rb

Overview

Don’t represent file modes as Strings containing octal values.

Examples:


### incorrect
file '/etc/some_file' do
  mode '0o755'
end

### correct
file '/etc/some_file' do
  mode '0755'
end

Constant Summary collapse

MSG =
"Don't represent file modes as strings containing octal values. Use standard base 10 file modes instead. For example: '0755'."
RESTRICT_ON_SEND =
[:mode].freeze

Instance Method Summary collapse

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_send(node) ⇒ Object



40
41
42
43
# File 'lib/rubocop/cop/chef/correctness/octal_mode_as_string.rb', line 40

def on_send(node)
  return unless node.arguments.first&.str_type? && node.arguments.first.value.match?(/^0o/)
  add_offense(node, severity: :refactor)
end