waveclaw/puppet-facter_cacheable

View on GitHub
lib/facter/util/facter_cacheable.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Method find_cache has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def find_cache(key, source)
      unless key
        raise ArgumentError, 'No key was provided to check'
      end
      if !source
Severity: Minor
Found in lib/facter/util/facter_cacheable.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 cached? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def cached?(key, ttl = 3600, source = nil)
      cache = nil
      # which cache?
      mycache = find_cache(key, source)
      cache_file = mycache[:file]
Severity: Minor
Found in lib/facter/util/facter_cacheable.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 make_cache_path has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def make_cache_path(cache_dir)
      # Changed to recursively create directories for facts.
      if !cache_dir.nil? && !File.exist?(cache_dir)
        recursive = cache_dir.split('/')
        directory = ''
Severity: Minor
Found in lib/facter/util/facter_cacheable.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

Use meaningful heredoc delimiters.
Open

EOF
Severity: Minor
Found in lib/facter/util/facter_cacheable.rb by rubocop

This cop checks that your heredocs are using meaningful delimiters. By default it disallows END and EO*, and can be configured through blacklisting additional delimiters.

Example:

# good
<<-SQL
  SELECT * FROM foo
SQL

# bad
<<-END
  SELECT * FROM foo
END

# bad
<<-EOS
  SELECT * FROM foo
EOS

There are no issues that match your filters.

Category
Status