BaseSecrete/rorvswild

View on GitHub
lib/rorvswild/metrics/cpu.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Method initialize has 10 arguments (exceeds 4 allowed). Consider refactoring.
Open

        def initialize(user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice)
Severity: Major
Found in lib/rorvswild/metrics/cpu.rb - About 1 hr to fix

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

          def update
            if @old_stat && (new_stat = Stat.read)
              if (total = new_stat.total - @old_stat.total) > 0
                @user = (new_stat.user - @old_stat.user) * 100 / total
                @system = (new_stat.system - @old_stat.system) * 100 / total
    Severity: Minor
    Found in lib/rorvswild/metrics/cpu.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

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

            def self.parse(string)
              for row in string.lines
                if row.start_with?("cpu ")
                  array = row.split[1..-1].map(&:to_i)[0,10]
                  array.fill(0, array.size, 10 - array.size) if array.size < 10
    Severity: Minor
    Found in lib/rorvswild/metrics/cpu.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

    There are no issues that match your filters.

    Category
    Status