ptomulik/puppet-portsng

View on GitHub

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
Severity: Minor
Found in lib/puppet/provider/package/portsng.rb - About 4 hrs to fix

    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|
    Severity: Minor
    Found in lib/puppet/provider/package/portsng.rb - About 1 hr to fix

    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
    Severity: Minor
    Found in lib/puppet/provider/package/portsng.rb - About 1 hr to fix

      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]
      Severity: Minor
      Found in lib/puppet/provider/package/portsng.rb - About 55 mins to fix

      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 " \
      Severity: Minor
      Found in lib/puppet/provider/package/portsng.rb - About 35 mins to fix

      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
      Severity: Minor
      Found in spec/spec_helper_acceptance.rb by rubocop

      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 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)'
      Severity: Minor
      Found in lib/puppet/provider/package/portsng.rb - About 25 mins to fix

      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 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
      Severity: Minor
      Found in lib/puppet/provider/package/portsng.rb - About 25 mins to fix

      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

      Gem puppetlabs_spec_helper requirements already given on line 23 of the Gemfile.
      Open

          gem 'puppetlabs_spec_helper', '< 2.0.0', :require => false
      Severity: Minor
      Found in Gemfile by rubocop

      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]

      Empty line detected around arguments.
      Open

      
        `package_settings` shall be a hash with port's option names as keys (all

      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
      )

      %w-literals should be delimited by [ and ].
      Open

        self::DEFAULT_UPGRADE_OPTIONS = %w(-R -M BATCH=yes).freeze

      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)

      Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem puppetlabs_spec_helper should appear before rake.
      Open

          gem 'puppetlabs_spec_helper', :require => false
      Severity: Minor
      Found in Gemfile by rubocop

      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'

      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'] || '>= 3.2.0')
      Severity: Minor
      Found in Gemfile by rubocop

      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'

      %w-literals should be delimited by [ and ].
      Open

        self::DEFAULT_INSTALL_OPTIONS = %w(-N -M BATCH=yes).freeze

      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)

      %w-literals should be delimited by [ and ].
      Open

          self::DEFAULT_UNINSTALL_OPTIONS = %w().freeze

      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)

      Use && instead of and.
      Open

        if ENV['PUPPET_GEM_VERSION'] and ENV['PUPPET_GEM_VERSION'] =~ /^\s*(~>\s*3\.[01])|(<\s*3\.2(\.0)?)|(<=\s*3\.1)/
      Severity: Minor
      Found in Gemfile by rubocop

      This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

      Example: EnforcedStyle: always (default)

      # bad
      foo.save and return
      
      # bad
      if foo and bar
      end
      
      # good
      foo.save && return
      
      # good
      if foo && bar
      end

      Example: EnforcedStyle: conditionals

      # bad
      if foo and bar
      end
      
      # good
      foo.save && return
      
      # good
      foo.save and return
      
      # good
      if foo && bar
      end

      %w-literals should be delimited by [ and ].
      Open

          prepare_options(ops, self.class::DEFAULT_INSTALL_OPTIONS, %w(-N), %w(-R -f))

      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)

      %w-literals should be delimited by [ and ].
      Open

          prepare_options(ops, self.class::DEFAULT_REINSTALL_OPTIONS, %w(-f), %w(-N))

      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')
      Severity: Minor
      Found in Gemfile by rubocop

      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]

      %w-literals should be delimited by [ and ].
      Open

        %w(INTERACTIVE UNAME).each do |var|

      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)
      Severity
      Category
      Status
      Source
      Language