rapid7/metasploit-framework

View on GitHub
docs/build.rb

Summary

Maintainability
D
2 days
Test Coverage

File build.rb has 476 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'fileutils'
require 'uri'
require 'open3'
require 'optparse'
require 'did_you_mean'
Severity: Minor
Found in docs/build.rb - About 7 hrs to fix

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

        def run(config, options = {})
          begin
            config.validate!
          rescue
            puts "[!] Validation failed. Please verify navigation.rb is valid, as well as the markdown file"
    Severity: Minor
    Found in docs/build.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 run has 55 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.run(options)
        Git.clone_wiki! if options[:wiki_pull]
    
        # Create a new branch based on the commits from https://github.com/rapid7/metasploit-framework/wiki to move
        # Wiki files into the metasploit-framework repo
    Severity: Major
    Found in docs/build.rb - About 2 hrs to fix

      Method run has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def run(config, options = {})
            begin
              config.validate!
            rescue
              puts "[!] Validation failed. Please verify navigation.rb is valid, as well as the markdown file"
      Severity: Minor
      Found in docs/build.rb - About 1 hr to fix

        Method run_command has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.run_command(command, exception: true)
            puts "[*] #{command}"
            result = ''
            ::Open3.popen2e(
              { 'BUNDLE_GEMFILE' => File.join(Dir.pwd, 'Gemfile') },
        Severity: Minor
        Found in docs/build.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 run has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.run(options)
            Git.clone_wiki! if options[:wiki_pull]
        
            # Create a new branch based on the commits from https://github.com/rapid7/metasploit-framework/wiki to move
            # Wiki files into the metasploit-framework repo
        Severity: Minor
        Found in docs/build.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 extract_relative_links has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def extract_relative_links(markdown)
              existing_links = @links
              new_links = {}
        
              markdown.scan(/(\[\[([\w\/_ '().:,-]+)(?:\|([\w\/_ '():,.#-]+))?\]\])/) do |full_match, left, right|
        Severity: Minor
        Found in docs/build.rb - About 1 hr to fix

          Method extract_relative_links has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def extract_relative_links(markdown)
                existing_links = @links
                new_links = {}
          
                markdown.scan(/(\[\[([\w\/_ '().:,-]+)(?:\|([\w\/_ '():,.#-]+))?\]\])/) do |full_match, left, right|
          Severity: Minor
          Found in docs/build.rb - About 55 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 validate! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def validate!
                configured_paths = all_file_paths
                missing_paths = available_paths.map { |path| path.gsub("#{WIKI_PATH}/", '') } - ignored_paths - existing_docs - configured_paths
                raise ConfigValidationError, "Unhandled paths #{missing_paths.join(', ')} - add navigation entries to navigation.rb for these files" if missing_paths.any?
          
          
          Severity: Minor
          Found in docs/build.rb - About 55 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 with_metadata has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def with_metadata(child, parents: [])
                child = child.clone
          
                if child[:folder]
                  parent_folders = parents.map { |page| page[:folder] }
          Severity: Minor
          Found in docs/build.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 new_path_for has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def new_path_for(old_path, old_path_anchor)
                # Strip out any leading `./` or `/` before the relative path.
                # This is needed for our later code that does additional filtering for
                # potential ambiguity with absolute paths since those comparisons occur
                # against filenames without the leading ./ and / parts.
          Severity: Minor
          Found in docs/build.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 link_corrector_for has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def link_corrector_for(config)
                link_corrector = LinkCorrector.new(config)
                errors = []
                config.each do |page|
                  unless page[:path].nil?
          Severity: Minor
          Found in docs/build.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

          There are no issues that match your filters.

          Category
          Status