postmodern/wordlist.rb

View on GitHub

Showing 8 of 12 total issues

Method option_parser has 117 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def option_parser
      OptionParser.new do |opts|
        opts.banner = "usage: #{PROGRAM_NAME} { [options] WORDLIST ... | --build WORDLIST [FILE ...] }"

        opts.separator ""
Severity: Major
Found in lib/wordlist/cli.rb - About 4 hrs to fix

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

        def parse(text,&block)
          return enum_for(__method__,text).to_a unless block_given?
    
          scanner = StringScanner.new(text)
    
    
    Severity: Minor
    Found in lib/wordlist/lexer.rb - About 2 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

    File cli.rb has 260 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require_relative 'file'
    require_relative 'builder'
    require_relative 'version'
    
    require 'optparse'
    Severity: Minor
    Found in lib/wordlist/cli.rb - About 2 hrs to fix

      Method initialize has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def initialize(lang:          Lang.default,
                         stop_words:    StopWords[lang],
                         ignore_words:  [],
                         digits:   true,
                         special_chars:  SPECIAL_CHARS,
      Severity: Minor
      Found in lib/wordlist/lexer.rb - About 1 hr to fix

        Method read_mode has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def read_mode(argv)
              unless argv.length >= 1
                print_error "too few arguments given, requires at least one WORDLIST argument"
                print_error "usage: #{PROGRAM_NAME} [options] WORDLIST ..."
                return -1
        Severity: Minor
        Found in lib/wordlist/cli.rb - About 1 hr to fix

          Method command has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def self.command(path, format: , append: false)
                  case format
                  when :gzip, :bzip2, :xz
                    command  = format.to_s
                    redirect = if append then '>>'
          Severity: Minor
          Found in lib/wordlist/compression/writer.rb - About 45 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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def initialize(lang:          Lang.default,
                             stop_words:    StopWords[lang],
                             ignore_words:  [],
                             digits:   true,
                             special_chars:  SPECIAL_CHARS,
          Severity: Minor
          Found in lib/wordlist/lexer.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 each has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def each
                return enum_for(__method__) unless block_given?
          
                each_line do |line|
                  line.chomp!
          Severity: Minor
          Found in lib/wordlist/file.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

          Severity
          Category
          Status
          Source
          Language