puppetlabs/facter

View on GitHub

Showing 386 of 386 total issues

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

  module Alpine
    module Os
      class Release
        FACT_NAME = 'os.release'
        ALIASES = %w[operatingsystemmajrelease operatingsystemrelease].freeze
Severity: Major
Found in lib/facter/facts/alpine/os/release.rb and 6 other locations - About 1 hr to fix
lib/facter/facts/devuan/os/release.rb on lines 4..24
lib/facter/facts/gentoo/os/release.rb on lines 4..24
lib/facter/facts/meego/os/release.rb on lines 4..24
lib/facter/facts/oel/os/release.rb on lines 4..24
lib/facter/facts/ol/os/release.rb on lines 4..24
lib/facter/facts/ovs/os/release.rb on lines 4..24

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 70.

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 7 locations. Consider refactoring.
Open

  module Devuan
    module Os
      class Release
        FACT_NAME = 'os.release'
        ALIASES = %w[operatingsystemmajrelease operatingsystemrelease].freeze
Severity: Major
Found in lib/facter/facts/devuan/os/release.rb and 6 other locations - About 1 hr to fix
lib/facter/facts/alpine/os/release.rb on lines 4..24
lib/facter/facts/gentoo/os/release.rb on lines 4..24
lib/facter/facts/meego/os/release.rb on lines 4..24
lib/facter/facts/oel/os/release.rb on lines 4..24
lib/facter/facts/ol/os/release.rb on lines 4..24
lib/facter/facts/ovs/os/release.rb on lines 4..24

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 70.

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 7 locations. Consider refactoring.
Open

  module Ovs
    module Os
      class Release
        FACT_NAME = 'os.release'
        ALIASES = %w[operatingsystemmajrelease operatingsystemrelease].freeze
Severity: Major
Found in lib/facter/facts/ovs/os/release.rb and 6 other locations - About 1 hr to fix
lib/facter/facts/alpine/os/release.rb on lines 4..24
lib/facter/facts/devuan/os/release.rb on lines 4..24
lib/facter/facts/gentoo/os/release.rb on lines 4..24
lib/facter/facts/meego/os/release.rb on lines 4..24
lib/facter/facts/oel/os/release.rb on lines 4..24
lib/facter/facts/ol/os/release.rb on lines 4..24

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 70.

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 7 locations. Consider refactoring.
Open

  module Ol
    module Os
      class Release
        FACT_NAME = 'os.release'
        ALIASES = %w[operatingsystemmajrelease operatingsystemrelease].freeze
Severity: Major
Found in lib/facter/facts/ol/os/release.rb and 6 other locations - About 1 hr to fix
lib/facter/facts/alpine/os/release.rb on lines 4..24
lib/facter/facts/devuan/os/release.rb on lines 4..24
lib/facter/facts/gentoo/os/release.rb on lines 4..24
lib/facter/facts/meego/os/release.rb on lines 4..24
lib/facter/facts/oel/os/release.rb on lines 4..24
lib/facter/facts/ovs/os/release.rb on lines 4..24

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 70.

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 7 locations. Consider refactoring.
Open

  module Oel
    module Os
      class Release
        FACT_NAME = 'os.release'
        ALIASES = %w[operatingsystemmajrelease operatingsystemrelease].freeze
Severity: Major
Found in lib/facter/facts/oel/os/release.rb and 6 other locations - About 1 hr to fix
lib/facter/facts/alpine/os/release.rb on lines 4..24
lib/facter/facts/devuan/os/release.rb on lines 4..24
lib/facter/facts/gentoo/os/release.rb on lines 4..24
lib/facter/facts/meego/os/release.rb on lines 4..24
lib/facter/facts/ol/os/release.rb on lines 4..24
lib/facter/facts/ovs/os/release.rb on lines 4..24

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 70.

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_commit has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_commit(commit)
    prs = client.commit_pulls('puppetlabs/facter', commit.sha, { accept: 'application/vnd.github.groot-preview+json' })

    prs.each do |pr|
      next if pr[:state] != 'closed' && pr[:merged_at].nil?
Severity: Minor
Found in scripts/generate_changelog.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 find_in_interfaces has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

            def find_in_interfaces(interfaces)
              return if interfaces.nil?

              interfaces.each do |iface_name, interface|
                interface[:bindings]&.each do |binding|
Severity: Minor
Found in lib/facter/util/resolvers/networking/primary_interface.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

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

  module Solaris
    class DhcpServers
      FACT_NAME = 'dhcp_servers'
      TYPE = :legacy

Severity: Major
Found in lib/facter/facts/solaris/dhcp_servers.rb and 1 other location - About 1 hr to fix
lib/facter/facts/linux/dhcp_servers.rb on lines 4..24

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 64.

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 Linux
    class DhcpServers
      FACT_NAME = 'dhcp_servers'
      TYPE = :legacy

Severity: Major
Found in lib/facter/facts/linux/dhcp_servers.rb and 1 other location - About 1 hr to fix
lib/facter/facts/solaris/dhcp_servers.rb on lines 4..24

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 64.

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 execute_command has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def execute_command(command, on_fail = nil, logger = nil, timeout = nil)
          timeout ||= DEFAULT_EXECUTION_TIMEOUT
          begin
            # Set LC_ALL and LANG to force i18n to C for the duration of this exec;
            # this ensures that any code that parses the
Severity: Minor
Found in lib/facter/custom_facts/core/execution/base.rb - About 1 hr to fix

    Method call_the_resolver has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

            def call_the_resolver
              provider = case Facter::Util::Facts::Posix::VirtualDetector.platform
                         when 'hyperv'
                           metadata = Facter::Resolvers::Az.resolve(:metadata)
                           'azure' unless metadata.nil? || metadata.empty?
    Severity: Minor
    Found in lib/facter/facts/linux/cloud/provider.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 deep_merge has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

          def deep_merge(left, right, path = [])
            ret = nil
    
            if left.is_a?(Hash) && right.is_a?(Hash)
              ret = left.merge(right) do |key, left_val, right_val|
    Severity: Minor
    Found in lib/facter/custom_facts/util/values.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 retrieve_vserver has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

            def retrieve_vserver
              proc_status_content = Facter::Util::FileHelper.safe_readlines('/proc/self/status', nil)
              return unless proc_status_content
    
              proc_status_content.each do |line|
    Severity: Minor
    Found in lib/facter/resolvers/virt_what.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 search has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def search(json_data, searched_element, path)
          # we hit a dead end, the os was not found on this branch
          # and we cannot go deeper
          return unless json_data
    
    
    Severity: Minor
    Found in lib/facter/framework/detector/os_hierarchy.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 retrieve_info has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

            def retrieve_info(fact_name)
              ssh_list = []
              FILE_PATHS.each do |file_path|
                next unless File.directory?(file_path)
    
    
    Severity: Minor
    Found in lib/facter/resolvers/ssh.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 call_the_resolver has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

            def call_the_resolver
              virtual = Facter::Resolvers::Windows::Virtualization.resolve(:virtual)
              provider = case virtual
                         when 'hyperv'
                           metadata = Facter::Resolvers::Az.resolve(:metadata)
    Severity: Minor
    Found in lib/facter/facts/windows/cloud/provider.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_proc_status has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

            def read_proc_status
              proc_status_content = Facter::Util::FileHelper.safe_readlines('/proc/self/status', nil)
              return unless proc_status_content
    
              proc_status_content.each do |line|
    Severity: Minor
    Found in lib/facter/resolvers/open_vz.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 compute_sizes(info)
                available_bytes = info[3]
                used_bytes = info[2]
                size_bytes = info[1]
                @fact_list[:mountpoints][info.last].merge!(
    Severity: Major
    Found in lib/facter/resolvers/aix/mountpoints.rb and 1 other location - About 1 hr to fix
    lib/facter/resolvers/openbsd/mountpoints.rb on lines 54..66

    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 57.

    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 compute_sizes(info)
                available_bytes = info[3]
                used_bytes = info[2]
                size_bytes = info[1]
                @fact_list[:mountpoints][info.last].merge!(
    Severity: Major
    Found in lib/facter/resolvers/openbsd/mountpoints.rb and 1 other location - About 1 hr to fix
    lib/facter/resolvers/aix/mountpoints.rb on lines 57..69

    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 57.

    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 Solaris
        class Ssh
          FACT_NAME = 'ssh'
    
          def call_the_resolver
    Severity: Major
    Found in lib/facter/facts/solaris/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/macosx/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

    Severity
    Category
    Status
    Source
    Language