crowbar/crowbar-openstack

View on GitHub
chef/cookbooks/postgresql/libraries/default.rb

Summary

Maintainability
C
1 day
Test Coverage

Method scan_available_timezones has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

def scan_available_timezones(tzdir)
    # There should be an /etc/localtime zoneinfo file that is a link to
    # (or a copy of) a timezone data file under tzdir, which should have
    # been installed under the "share" directory by the tzdata package.
    #
Severity: Minor
Found in chef/cookbooks/postgresql/libraries/default.rb - About 4 hrs 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 binaryround has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def binaryround(value)

    # Keep a multiplier which grows through powers of 1
    multiplier = 1

Severity: Minor
Found in chef/cookbooks/postgresql/libraries/default.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 binaryround has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def binaryround(value)

    # Keep a multiplier which grows through powers of 1
    multiplier = 1

Severity: Minor
Found in chef/cookbooks/postgresql/libraries/default.rb - About 1 hr to fix

Method scan_available_timezones has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def scan_available_timezones(tzdir)
    # There should be an /etc/localtime zoneinfo file that is a link to
    # (or a copy of) a timezone data file under tzdir, which should have
    # been installed under the "share" directory by the tzdata package.
    #
Severity: Minor
Found in chef/cookbooks/postgresql/libraries/default.rb - About 1 hr to fix

Avoid deeply nested control flow statements.
Open

                        if validate_zone(tzname)
                            if (bestzonename.nil? ||
                            tzname.length < bestzonename.length ||
                            (tzname.length == bestzonename.length &&
                                 (tzname <=> bestzonename) < 0)
Severity: Major
Found in chef/cookbooks/postgresql/libraries/default.rb - About 45 mins to fix

Method identify_system_timezone has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def identify_system_timezone(tzdir)
    resultbuf = scan_available_timezones(tzdir)

    if !resultbuf.nil?
        # Ignore Olson's rather silly "Factory" zone; use GMT instead
Severity: Minor
Found in chef/cookbooks/postgresql/libraries/default.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

Avoid too many return statements within this method.
Open

        return "mdy"
Severity: Major
Found in chef/cookbooks/postgresql/libraries/default.rb - About 30 mins to fix

There are no issues that match your filters.

Category
Status