mcanevet/rspec-puppet-facts

View on GitHub

Showing 7 of 7 total issues

Method on_supported_os_implementation has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
Open

  def on_supported_os_implementation(opts = {})
    unless /\A\d+\.\d+(?:\.\d+)*\z/.match?((facterversion = opts[:facterversion]))
      raise ArgumentError, ":facterversion must be in the format 'n.n' or " \
        "'n.n.n' (n is numeric), not '#{facterversion}'"
    end
Severity: Minor
Found in lib/rspec-puppet-facts.rb - About 1 day 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 on_supported_os_implementation has 95 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def on_supported_os_implementation(opts = {})
    unless /\A\d+\.\d+(?:\.\d+)*\z/.match?((facterversion = opts[:facterversion]))
      raise ArgumentError, ":facterversion must be in the format 'n.n' or " \
        "'n.n.n' (n is numeric), not '#{facterversion}'"
    end
Severity: Major
Found in lib/rspec-puppet-facts.rb - About 3 hrs to fix

    File rspec-puppet-facts.rb has 262 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'puppet'
    require 'facter'
    require 'facterdb'
    require 'json'
    require 'deep_merge'
    Severity: Minor
    Found in lib/rspec-puppet-facts.rb - About 2 hrs to fix

      Method with_custom_facts has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.with_custom_facts(os, facts)
          return facts unless @custom_facts
      
          @custom_facts.each do |name, fact|
            next if fact[:options][:confine] && !fact[:options][:confine].include?(os)
      Severity: Minor
      Found in lib/rspec-puppet-facts.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 facter_version_for_puppet_version has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.facter_version_for_puppet_version(puppet_version)
          return Facter.version if puppet_version.nil?
      
          json_path = File.expand_path(File.join(__dir__, '..', 'ext', 'puppet_agent_components.json'))
          unless File.file?(json_path) && File.readable?(json_path)
      Severity: Minor
      Found in lib/rspec-puppet-facts.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 facter_version_for_puppet_version has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.facter_version_for_puppet_version(puppet_version)
          return Facter.version if puppet_version.nil?
      
          json_path = File.expand_path(File.join(__dir__, '..', 'ext', 'puppet_agent_components.json'))
          unless File.file?(json_path) && File.readable?(json_path)
      Severity: Minor
      Found in lib/rspec-puppet-facts.rb - About 1 hr to fix

        Method on_supported_os has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def on_supported_os(opts = {})
            opts[:hardwaremodels] ||= ['x86_64']
            opts[:hardwaremodels] = [opts[:hardwaremodels]] unless opts[:hardwaremodels].is_a? Array
            opts[:supported_os] ||= RspecPuppetFacts.meta_supported_os
            opts[:facterversion] ||= RSpec.configuration.default_facter_version
        Severity: Minor
        Found in lib/rspec-puppet-facts.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

        Severity
        Category
        Status
        Source
        Language