Showing 55 of 55 total issues
File portsng.rb
has 373 lines of code (exceeds 250 allowed). Consider refactoring. Open
%w(vash portsutil backports).each do |p|
dir = File.join(File.dirname(__FILE__), "../../../../../#{p}/lib")
dir = File.expand_path(dir)
$LOAD_PATH.unshift(dir) if !$LOAD_PATH.include?(dir) && File.directory?(dir)
end
Method prepare_options
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def prepare_options(options, defaults, extra = [], deny = [])
return defaults.dup unless options
# handle {option => value} hashes and flatten nested arrays
options = options.collect do |x|
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method latest
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def latest
# If there's no "latest" version, we just return a placeholder
result = :latest
oldversion = properties[:ensure]
case portstatus
Method instances_from_package_records
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.instances_from_package_records(records, options)
packages = []
with_unique('installed ports', records) do |pkgname, rec|
unless rec[:portorigin] && ['<', '=', '>'].include?(rec[:portstatus])
rec.delete(:portorigin) if rec[:portorigin]
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method package_settings_validate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def package_settings_validate(opts)
return true unless opts # options not defined
options_class = Puppet::Util::PTomulik::Package::Ports::Options
unless opts.is_a?(Hash) || opts.is_a?(options_class)
raise ArgumentError, "#{opts.inspect} of type #{opts.class} is not an " \
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Block has too many lines. [28/25] Open
RSpec.configure do |c|
# Project root
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
# Readable test descriptions
- Read upRead up
- Exclude checks
This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.
Method latest
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def latest
# If there's no "latest" version, we just return a placeholder
result = :latest
oldversion = properties[:ensure]
case portstatus
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method validate_package_setting
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def validate_package_setting(key, value)
options_class = Puppet::Util::PTomulik::Package::Ports::Options
unless options_class.option_name?(key)
raise ArgumentError, "#{key.inspect} is not a valid option name (for" \
' $package_settings)'
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Line is too long. [89/80] Open
versions = ['9.0', '9.1', '9.2', '9.3', '10.1', '10.2', '10.3', '11.0', '11.1', '12.0']
- Exclude checks
%w
-literals should be delimited by [
and ]
. Open
prepare_options(ops, self.class::DEFAULT_INSTALL_OPTIONS, %w(-N), %w(-R -f))
- Read upRead up
- Exclude checks
This cop enforces the consistent usage of %
-literal delimiters.
Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.
Example:
# Style/PercentLiteralDelimiters:
# PreferredDelimiters:
# default: '[]'
# '%i': '()'
# good
%w[alpha beta] + %i(gamma delta)
# bad
%W(alpha #{beta})
# bad
%I(alpha beta)
Gem beaker-rspec
requirements already given on line 54 of the Gemfile. Open
gem 'beaker-rspec', *location_for(ENV['BEAKER_RSPEC_VERSION'] || '>= 3.4')
- Read upRead up
- Exclude checks
A Gem's requirements should be listed only once in a Gemfile.
Example:
# bad
gem 'rubocop'
gem 'rubocop'
# bad
group :development do
gem 'rubocop'
end
group :test do
gem 'rubocop'
end
# good
group :development, :test do
gem 'rubocop'
end
# good
gem 'rubocop', groups: [:development, :test]
Avoid multi-line ternary operators, use if
or unless
instead. Open
default_puppet = host['platform'] =~ /9\.[0-1]/ ? 'puppet' :
(host['platform'] =~ /10\.[0-4]/ ? 'puppet4' : 'puppet5')
- Read upRead up
- Exclude checks
This cop checks for multi-line ternary op expressions.
Example:
# bad
a = cond ?
b : c
a = cond ? b :
c
a = cond ?
b :
c
# good
a = cond ? b : c
a =
if cond
b
else
c
end
Empty line detected around arguments. Open
`package_settings` shall be a hash with port's option names as keys (all
- Read upRead up
- Exclude checks
This cops checks if empty lines exist around the arguments of a method invocation.
Example:
# bad
do_something(
foo
)
process(bar,
baz: qux,
thud: fred)
some_method(
[1,2,3],
x: y
)
# good
do_something(
foo
)
process(bar,
baz: qux,
thud: fred)
some_method(
[1,2,3],
x: y
)
Empty line detected around arguments. Open
package { 'www/apache22':
- Read upRead up
- Exclude checks
This cops checks if empty lines exist around the arguments of a method invocation.
Example:
# bad
do_something(
foo
)
process(bar,
baz: qux,
thud: fred)
some_method(
[1,2,3],
x: y
)
# good
do_something(
foo
)
process(bar,
baz: qux,
thud: fred)
some_method(
[1,2,3],
x: y
)
Empty line detected around arguments. Open
`install_options` are passed to `portupgrade` command when installing,
- Read upRead up
- Exclude checks
This cops checks if empty lines exist around the arguments of a method invocation.
Example:
# bad
do_something(
foo
)
process(bar,
baz: qux,
thud: fred)
some_method(
[1,2,3],
x: y
)
# good
do_something(
foo
)
process(bar,
baz: qux,
thud: fred)
some_method(
[1,2,3],
x: y
)
Empty line detected around arguments. Open
`uninstall_options` are passed to uninstall command. When the target system
- Read upRead up
- Exclude checks
This cops checks if empty lines exist around the arguments of a method invocation.
Example:
# bad
do_something(
foo
)
process(bar,
baz: qux,
thud: fred)
some_method(
[1,2,3],
x: y
)
# good
do_something(
foo
)
process(bar,
baz: qux,
thud: fred)
some_method(
[1,2,3],
x: y
)
Gem rspec-puppet
requirements already given on line 36 of the Gemfile. Open
gem 'rspec-puppet'
- Read upRead up
- Exclude checks
A Gem's requirements should be listed only once in a Gemfile.
Example:
# bad
gem 'rubocop'
gem 'rubocop'
# bad
group :development do
gem 'rubocop'
end
group :test do
gem 'rubocop'
end
# good
group :development, :test do
gem 'rubocop'
end
# good
gem 'rubocop', groups: [:development, :test]
Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem beaker
should appear before beaker-rspec
. Open
gem 'beaker', *location_for(ENV['BEAKER_VERSION'] || '~> 2')
- Read upRead up
- Exclude checks
Gems should be alphabetically sorted within groups.
Example:
# bad
gem 'rubocop'
gem 'rspec'
# good
gem 'rspec'
gem 'rubocop'
# good
gem 'rubocop'
gem 'rspec'
# good only if TreatCommentsAsGroupSeparators is true
# For code quality
gem 'rubocop'
# For tests
gem 'rspec'
Line is too long. [113/80] Open
if ENV['PUPPET_GEM_VERSION'] and ENV['PUPPET_GEM_VERSION'] =~ /^\s*(~>\s*3\.[01])|(<\s*3\.2(\.0)?)|(<=\s*3\.1)/
- Exclude checks
Gem nokogiri
requirements already given on line 46 of the Gemfile. Open
gem 'nokogiri', '< 1.7', :require => false
- Read upRead up
- Exclude checks
A Gem's requirements should be listed only once in a Gemfile.
Example:
# bad
gem 'rubocop'
gem 'rubocop'
# bad
group :development do
gem 'rubocop'
end
group :test do
gem 'rubocop'
end
# good
group :development, :test do
gem 'rubocop'
end
# good
gem 'rubocop', groups: [:development, :test]