tlab-jp/rakudax

View on GitHub
lib/rakudax/base.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method has too many lines. [52/30]
Open

    def self.parse_options(argv)
      if argv.empty?
        self.exit_with_message 2, true
      end

Severity: Minor
Found in lib/rakudax/base.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Cyclomatic complexity for parse_options is too high. [19/6]
Open

    def self.parse_options(argv)
      if argv.empty?
        self.exit_with_message 2, true
      end

Severity: Minor
Found in lib/rakudax/base.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Class Base has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Base
    require 'pathname'
    USAGE=<<-EOS
===========================================================================
<>: required
Severity: Minor
Found in lib/rakudax/base.rb - About 2 hrs to fix

    Method parse_options has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.parse_options(argv)
          if argv.empty?
            self.exit_with_message 2, true
          end
    
    
    Severity: Major
    Found in lib/rakudax/base.rb - About 2 hrs to fix

      Method load_dbconfig has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.load_dbconfig(str)
            path = Pathname.new str
            path = self.root.join(str) unless path.absolute?
            @@dbconfig = YAML.load(
              File.read(
      Severity: Minor
      Found in lib/rakudax/base.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_options has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.parse_options(argv)
            if argv.empty?
              self.exit_with_message 2, true
            end
      
      
      Severity: Minor
      Found in lib/rakudax/base.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

      Use == if you meant to do a comparison or wrap the expression in parentheses to indicate you meant to assign in a condition.
      Open

            while arg = argv.shift
      Severity: Minor
      Found in lib/rakudax/base.rb by rubocop

      This cop checks for assignments in the conditions of if/while/until.

      Example:

      # bad
      
      if some_var = true
        do_something
      end

      Example:

      # good
      
      if some_var == true
        do_something
      end

      There are no issues that match your filters.

      Category
      Status