puppetlabs/facter

View on GitHub

Showing 386 of 386 total issues

Similar blocks of code found in 4 locations. Consider refactoring.
Open

  module Linux
    class Ssh
      FACT_NAME = 'ssh'

      def call_the_resolver
Severity: Major
Found in lib/facter/facts/linux/ssh.rb and 3 other locations - About 1 hr to fix
lib/facter/facts/aix/ssh.rb on lines 4..32
lib/facter/facts/macosx/ssh.rb on lines 4..32
lib/facter/facts/solaris/ssh.rb on lines 4..32

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 56.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

  module Macosx
    class Ssh
      FACT_NAME = 'ssh'

      def call_the_resolver
Severity: Major
Found in lib/facter/facts/macosx/ssh.rb and 3 other locations - About 1 hr to fix
lib/facter/facts/aix/ssh.rb on lines 4..32
lib/facter/facts/linux/ssh.rb on lines 4..32
lib/facter/facts/solaris/ssh.rb on lines 4..32

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 56.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

  module Aix
    class Ssh
      FACT_NAME = 'ssh'

      def call_the_resolver
Severity: Major
Found in lib/facter/facts/aix/ssh.rb and 3 other locations - About 1 hr to fix
lib/facter/facts/linux/ssh.rb on lines 4..32
lib/facter/facts/macosx/ssh.rb on lines 4..32
lib/facter/facts/solaris/ssh.rb on lines 4..32

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 56.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  module Resolvers
    class DMIBios < BaseResolver
      @log = Facter::Log.new(self)
      init_resolver

Severity: Major
Found in lib/facter/resolvers/windows/dmi_bios.rb and 1 other location - About 1 hr to fix
lib/facter/resolvers/windows/dmi_computersystem.rb on lines 4..34

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 56.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  module Resolvers
    class DMIComputerSystem < BaseResolver
      @log = Facter::Log.new(self)
      init_resolver

Severity: Major
Found in lib/facter/resolvers/windows/dmi_computersystem.rb and 1 other location - About 1 hr to fix
lib/facter/resolvers/windows/dmi_bios.rb on lines 4..35

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 56.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method load_facts_ttls has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def load_facts_ttls
      @facts_ttls ||= {}
      return if @groups_ttls == []

      @groups_ttls.reduce(:merge).each do |group, ttls|
Severity: Minor
Found in lib/facter/framework/config/fact_groups.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 true? has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def true?
        if @block && !@fact
          begin
            return !!@block.call
          rescue StandardError => e
Severity: Minor
Found in lib/facter/custom_facts/util/confine.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 load_env has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def load_env(fact = nil)
        # Load from the environment, if possible
        @environment_vars.each do |name, value|
          # Skip anything that doesn't match our regex.
          next unless name =~ /^facter_?(\w+)$/i
Severity: Minor
Found in lib/facter/custom_facts/util/loader.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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

      def check_other_facts
        isa = Facter::Resolvers::Uname.resolve(:processor)
        klass = isa == 'sparc' ? 'DmiSparc' : 'Dmi'

        product_name = Facter::Resolvers::Solaris.const_get(klass).resolve(:product_name)
Severity: Major
Found in lib/facter/facts/solaris/virtual.rb and 1 other location - About 1 hr to fix
lib/facter/facts/solaris/is_virtual.rb on lines 43..56

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 54.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

      def check_other_facts
        isa = Facter::Resolvers::Uname.resolve(:processor)
        klass = isa == 'sparc' ? 'DmiSparc' : 'Dmi'

        product_name = Facter::Resolvers::Solaris.const_get(klass).resolve(:product_name)
Severity: Major
Found in lib/facter/facts/solaris/is_virtual.rb and 1 other location - About 1 hr to fix
lib/facter/facts/solaris/virtual.rb on lines 43..56

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 54.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method read_mounts has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

          def read_mounts(fact_name)
            @mounts = []
            @auto_home_paths = []
            begin
              Facter::Util::Resolvers::FilesystemHelper.read_mountpoints&.each do |fs|
Severity: Minor
Found in lib/facter/resolvers/solaris/mountpoints.rb - About 1 hr to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      module Freebsd
        class Ssh
          FACT_NAME = 'ssh'
    
          def call_the_resolver
    Severity: Major
    Found in lib/facter/facts/freebsd/ssh.rb and 1 other location - About 1 hr to fix
    lib/facter/facts/openbsd/ssh.rb on lines 4..22

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 51.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      module Openbsd
        class Ssh
          FACT_NAME = 'ssh'
    
          def call_the_resolver
    Severity: Major
    Found in lib/facter/facts/openbsd/ssh.rb and 1 other location - About 1 hr to fix
    lib/facter/facts/freebsd/ssh.rb on lines 4..22

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 51.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Method parse_instance has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def parse_instance(gce_data)
              instance_data = gce_data['instance']
              return if instance_data.nil? || instance_data.empty?
    
              # See https://cloud.google.com/compute/docs/metadata for information about these values
    Severity: Minor
    Found in lib/facter/resolvers/gce.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 partitions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def partitions
            parts = Facter::Resolvers::Partitions.resolve(:partitions)
            # We should exit early if we are running on a node with no partitions
            # (e.g. a diskless, netbooted VM)
            return nil unless parts
    Severity: Minor
    Found in lib/facter/facts/linux/partitions.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 prepended has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.prepended(receiver)
            exclude, print_caller = parse_options(ENV['API_DEBUG'])
    
            receiver_methods = receiver.instance_methods - Object.methods
            receiver_methods.each do |meth|
    Severity: Minor
    Found in lib/facter/util/api_debugger.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 mac_from_bonded_interface has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

              def mac_from_bonded_interface(interface_name)
                master = bond_master_of(interface_name)
                return unless master
    
                output = Facter::Util::FileHelper.safe_read("/proc/net/bonding/#{master}", nil)
    Severity: Minor
    Found in lib/facter/util/linux/socket_parser.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 query_for_metadata has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def query_for_metadata(url, container)
              metadata = get_data_from(url)
              metadata.each_line do |line|
                next if line.empty?
    
    
    Severity: Minor
    Found in lib/facter/resolvers/ec2.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 read_facts has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

              def read_facts(fact_name)
                files = %w[bios_date bios_vendor bios_version board_asset_tag board_vendor board_name
                           board_serial chassis_asset_tag chassis_type sys_vendor product_name
                           product_serial product_uuid product_version]
                return unless File.directory?('/sys/class/dmi')
    Severity: Minor
    Found in lib/facter/resolvers/dmi.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 parse_routes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

              def parse_routes(output, ipv4_type)
                routes = []
                output.each_line do |line|
                  parts = line.split(' ').compact
                  next if parts.include?('linkdown')
    Severity: Minor
    Found in lib/facter/util/linux/routing_table.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

    Severity
    Category
    Status
    Source
    Language