archivesspace/archivesspace

View on GitHub
launcher/backup/lib/trollop.rb

Summary

Maintainability
F
6 days
Test Coverage

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

  def parse cmdline=ARGV
    vals = {}
    required = {}

    opt :version, "Print version and exit" if @version unless @specs[:version] || @long["version"]
Severity: Minor
Found in launcher/backup/lib/trollop.rb - About 1 day 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

File trollop.rb has 490 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'date'

module Trollop

VERSION = "2.0"
Severity: Minor
Found in launcher/backup/lib/trollop.rb - About 7 hrs to fix

    Method each_arg has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

      def each_arg args
        remains = []
        i = 0
    
        until i >= args.length
    Severity: Minor
    Found in launcher/backup/lib/trollop.rb - About 5 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 opt has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

      def opt name, desc="", opts={}
        raise ArgumentError, "you already have an argument named '#{name}'" if @specs.member? name
    
        ## fill in :type
        opts[:type] = # normalize
    Severity: Minor
    Found in launcher/backup/lib/trollop.rb - About 5 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 educate has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

      def educate stream=$stdout
        width # hack: calculate it now; otherwise we have to be careful not to
              # call this unless the cursor's at the beginning of a line.
        left = {}
        @specs.each do |name, spec|
    Severity: Minor
    Found in launcher/backup/lib/trollop.rb - About 3 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 parse has 95 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def parse cmdline=ARGV
        vals = {}
        required = {}
    
        opt :version, "Print version and exit" if @version unless @specs[:version] || @long["version"]
    Severity: Major
    Found in launcher/backup/lib/trollop.rb - About 3 hrs to fix

      Method opt has 81 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def opt name, desc="", opts={}
          raise ArgumentError, "you already have an argument named '#{name}'" if @specs.member? name
      
          ## fill in :type
          opts[:type] = # normalize
      Severity: Major
      Found in launcher/backup/lib/trollop.rb - About 3 hrs to fix

        Method each_arg has 66 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def each_arg args
            remains = []
            i = 0
        
            until i >= args.length
        Severity: Major
        Found in launcher/backup/lib/trollop.rb - About 2 hrs to fix

          Class Parser has 22 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class Parser
          
            ## The set of values that indicate a flag option when passed as the
            ## +:type+ parameter of #opt.
            FLAG_TYPES = [:flag, :bool, :boolean]
          Severity: Minor
          Found in launcher/backup/lib/trollop.rb - About 2 hrs to fix

            Method educate has 55 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def educate stream=$stdout
                width # hack: calculate it now; otherwise we have to be careful not to
                      # call this unless the cursor's at the beginning of a line.
                left = {}
                @specs.each do |name, spec|
            Severity: Major
            Found in launcher/backup/lib/trollop.rb - About 2 hrs to fix

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

                def wrap_line str, opts={}
                  prefix = opts[:prefix] || 0
                  width = opts[:width] || (self.width - 1)
                  start = 0
                  ret = []
              Severity: Minor
              Found in launcher/backup/lib/trollop.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 resolve_default_short_options! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                def resolve_default_short_options!
                  @order.each do |type, name|
                    next unless type == :opt
                    opts = @specs[name]
                    next if opts[:short]
              Severity: Minor
              Found in launcher/backup/lib/trollop.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

              Avoid deeply nested control flow statements.
              Open

                            unless num_params_taken
                              if @stop_on_unknown
                                remains += args[i + 1 .. -1]
                                return remains
                              else
              Severity: Major
              Found in launcher/backup/lib/trollop.rb - About 45 mins to fix

                Avoid too many return statements within this method.
                Open

                          return remains
                Severity: Major
                Found in launcher/backup/lib/trollop.rb - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status