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

(PUP-11768) Additional Layout cops #9195

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 8 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ AllCops:
- 'lib/puppet/vendor/**/*'
- 'lib/puppet/pops/parser/eparser.rb'

# This cop would completely reformat defaults, so we skip it for now.
Layout/ArgumentAlignment:
# The formatting of defaults is unusual, so let's skip layout cops.
Layout:
Exclude:
- 'lib/puppet/defaults.rb'

Expand All @@ -33,6 +33,12 @@ Layout/ElseAlignment:
Exclude:
- 'lib/puppet/provider/package/*.rb'

# We don't mind when module and class keywords are aligned.
Layout/IndentationWidth:
AllowedPatterns: ['^\s*module']
Exclude:
- 'lib/puppet/provider/package/*.rb'

# puppet uses symbol booleans in types and providers to work around long standing
# bugs when trying to manage falsey pararameters and properties
Lint/BooleanSymbol:
Expand Down
90 changes: 1 addition & 89 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,94 +22,6 @@ I18n/GetText/DecorateStringFormattingUsingPercent:
I18n/RailsI18n/DecorateString:
Enabled: false

# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyleAlignWith, Severity.
# SupportedStylesAlignWith: keyword, variable, start_of_line
Layout/EndAlignment:
Enabled: false

# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
Layout/ExtraSpacing:
Enabled: false

# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
Layout/FirstArgumentIndentation:
Enabled: false

# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_brackets
Layout/FirstArrayElementIndentation:
Exclude:
- 'lib/puppet/file_serving/mount/file.rb'
- 'lib/puppet/functions/lookup.rb'
- 'lib/puppet/pops/loader/static_loader.rb'
- 'lib/puppet/pops/model/ast.rb'
- 'lib/puppet/pops/model/pn_transformer.rb'
- 'lib/puppet/pops/resource/resource_type_impl.rb'
- 'lib/puppet/pops/types/iterable.rb'
- 'lib/puppet/pops/types/p_uri_type.rb'
- 'lib/puppet/pops/types/types.rb'
- 'lib/puppet/provider/nameservice/pw.rb'
- 'lib/puppet/type/file/content.rb'

# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_braces
Layout/FirstHashElementIndentation:
Enabled: false

# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: consistent, align_parentheses
Layout/FirstParameterIndentation:
Exclude:
- 'lib/puppet/pal/pal_impl.rb'

# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
# SupportedHashRocketStyles: key, separator, table
# SupportedColonStyles: key, separator, table
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
Layout/HashAlignment:
Enabled: false

# This cop supports safe auto-correction (--auto-correct).
Layout/HeredocIndentation:
Enabled: false

# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: normal, indented_internal_methods
Layout/IndentationConsistency:
Enabled: false

# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: IndentationWidth, EnforcedStyle.
# SupportedStyles: spaces, tabs
Layout/IndentationStyle:
Exclude:
- 'lib/puppet/ffi/windows/structs.rb'
- 'lib/puppet/transaction.rb'

# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: Width, AllowedPatterns, IgnoredPatterns.
Layout/IndentationWidth:
Enabled: false

# This cop supports safe auto-correction (--auto-correct).
Layout/InitialIndentation:
Exclude:
- 'lib/puppet/parser/functions/require.rb'

# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment.
Layout/LeadingCommentSpace:
Enabled: false

# This cop supports safe auto-correction (--auto-correct).
Layout/LeadingEmptyLines:
Exclude:
Expand Down Expand Up @@ -1565,4 +1477,4 @@ Style/ZeroLengthPredicate:
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 580
Enabled: false
8 changes: 4 additions & 4 deletions ext/windows/service/daemon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
require 'puppet/util/windows/monkey_patches/process'

class WindowsDaemon < Puppet::Util::Windows::Daemon
CREATE_NEW_CONSOLE = 0x00000010
CREATE_NEW_CONSOLE = 0x00000010

@run_thread = nil
@LOG_TO_FILE = false
Expand Down Expand Up @@ -146,9 +146,9 @@ def report_windows_event(type,id,message)
eventlog = nil
eventlog = Puppet::Util::Windows::EventLog.open("Puppet")
eventlog.report_event(
:event_type => type, # EVENTLOG_ERROR_TYPE, etc
:event_id => id, # 0x01 or 0x02, 0x03 etc.
:data => message # "the message"
:event_type => type, # EVENTLOG_ERROR_TYPE, etc
:event_id => id, # 0x01 or 0x02, 0x03 etc.
:data => message # "the message"
)
rescue Exception
# Ignore all errors
Expand Down
4 changes: 2 additions & 2 deletions lib/hiera/puppet_function.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def self.init_dispatch
scope_param
param 'String',:key
param 'Any', :default
optional_param 'Any', :override
optional_param 'Any', :override
end

dispatch :hiera_block1 do
Expand Down Expand Up @@ -62,7 +62,7 @@ def hiera_block2(scope, key, override, &default_block)

def lookup(scope, key, default, has_default, override, &default_block)
unless Puppet[:strict] == :off
#TRANSLATORS 'lookup' is a puppet function and should not be translated
# TRANSLATORS 'lookup' is a puppet function and should not be translated
message = _("The function '%{class_name}' is deprecated in favor of using 'lookup'.") % { class_name: self.class.name }
message += ' '+ _("See https://puppet.com/docs/puppet/%{minor_version}/deprecated_language.html") %
{ minor_version: Puppet.minor_version }
Expand Down
10 changes: 5 additions & 5 deletions lib/puppet/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def find(application_name)
# @param [String] class_name the fully qualified name of the class to try to load
# @return [Class] the Class instance, or nil? if it could not be loaded.
def try_load_class(class_name)
return self.const_defined?(class_name) ? const_get(class_name) : nil
return self.const_defined?(class_name) ? const_get(class_name) : nil
end
private :try_load_class

Expand Down Expand Up @@ -365,8 +365,8 @@ def initialize(command_line = Puppet::Util::CommandLine.new)
# @api public
def app_defaults
Puppet::Settings.app_defaults_for_run_mode(self.class.run_mode).merge(
:name => name
)
:name => name
)
end

# Initialize application defaults. It's usually not necessary to override this method.
Expand Down Expand Up @@ -504,8 +504,8 @@ def configure_indirector_routes
def log_runtime_environment(extra_info=nil)
runtime_info = {
'puppet_version' => Puppet.version,
'ruby_version' => RUBY_VERSION,
'run_mode' => self.class.run_mode.name
'ruby_version' => RUBY_VERSION,
'run_mode' => self.class.run_mode.name
}
unless Puppet::Util::Platform.jruby_fips?
runtime_info['openssl_version'] = "'#{OpenSSL::OPENSSL_VERSION}'"
Expand Down
Loading