ronin-rb/ronin-nmap

View on GitHub

Showing 15 of 15 total issues

Method included has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def self.included(command)
          command.option :ip, value: {
                                type:  String,
                                usage: 'IP'
                              },
Severity: Major
Found in lib/ronin/nmap/cli/filtering_options.rb - About 2 hrs to fix

    Method filter_targets has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

            def filter_targets(xml)
              targets = xml.each_up_host.lazy
    
              unless @with_ips.empty?
                targets = filter_targets_by_ip(targets)
    Severity: Minor
    Found in lib/ronin/nmap/cli/filtering_options.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

    Method highlight_host has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

              def highlight_host(host,pattern)
                addresses = host.addresses
                hostnames = host.hostnames
    
                unless hostnames.empty?
    Severity: Minor
    Found in lib/ronin/nmap/cli/commands/grep.rb - About 1 hr to fix

      Method scan has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def self.scan(*targets, sudo: nil, **kwargs,&block)
            nmap = ::Nmap::Command.new(**kwargs,&block)
      
            nmap.targets ||= targets
      
      
      Severity: Minor
      Found in lib/ronin/nmap.rb - About 1 hr to fix

        Method host_as_json has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def self.host_as_json(host)
                  hash = {
                    start_time: host.start_time,
                    end_time:   host.end_time,
                    status:     status_as_json(host.status),
        Severity: Minor
        Found in lib/ronin/nmap/converters/json.rb - About 1 hr to fix

          Method print_target has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                    def print_target(host)
                      puts "[ #{host} ]"
                      puts
          
                      unless host.addresses.empty?
          Severity: Minor
          Found in lib/ronin/nmap/cli/commands/print.rb - About 1 hr to fix

            Method run has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                      def run(xml_file,output_file=nil)
                        unless File.file?(xml_file)
                          print_error "no such file or directory: #{xml_file}"
                          exit(-1)
                        end
            Severity: Minor
            Found in lib/ronin/nmap/cli/commands/convert.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 filter_targets has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def filter_targets(xml)
                      targets = xml.each_up_host.lazy
            
                      unless @with_ips.empty?
                        targets = filter_targets_by_ip(targets)
            Severity: Minor
            Found in lib/ronin/nmap/cli/filtering_options.rb - About 1 hr to fix

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

                        def highlight_host(host,pattern)
                          addresses = host.addresses
                          hostnames = host.hostnames
              
                          unless hostnames.empty?
              Severity: Minor
              Found in lib/ronin/nmap/cli/commands/grep.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 print_uris has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                        def print_uris(host)
                          filter_ports(host).each do |port|
                            if (port.service && port.service.name == 'http') ||
                               (port.number == 80)
                              puts URI::HTTP.build(
              Severity: Minor
              Found in lib/ronin/nmap/cli/commands/dump.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

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

                      def self.host_as_json(host)
                        hash = {
                          start_time: host.start_time,
                          end_time:   host.end_time,
                          status:     status_as_json(host.status),
              Severity: Minor
              Found in lib/ronin/nmap/converters/json.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

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

                        def run(*nmap_args)
                          if (output = options[:output])
                            output_format = options.fetch(:output_format) do
                                              infer_output_format(output)
                                            end
              Severity: Minor
              Found in lib/ronin/nmap/cli/commands/scan.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

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

                        def print_target(host)
                          puts "[ #{host} ]"
                          puts
              
                          unless host.addresses.empty?
              Severity: Minor
              Found in lib/ronin/nmap/cli/commands/print.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

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

                        def match_service(service,pattern)
                          product    = service.product
                          version    = service.version
                          extra_info = service.extra_info
              
              
              Severity: Minor
              Found in lib/ronin/nmap/cli/commands/grep.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 scan has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def self.scan(*targets, sudo: nil, **kwargs,&block)
                    nmap = ::Nmap::Command.new(**kwargs,&block)
              
                    nmap.targets ||= targets
              
              
              Severity: Minor
              Found in lib/ronin/nmap.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