hammackj/uirusu

View on GitHub
lib/uirusu/cli/application.rb

Summary

Maintainability
F
3 days
Test Coverage

Method scan_and_wait has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
Open

            def scan_and_wait(mod, resource, attempts)
                method = nil
                retries = attempts

                if mod.name == "Uirusu::VTFile"
Severity: Minor
Found in lib/uirusu/cli/application.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

Method main has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

            def main(args)
                parse_options(args)
                load_config

                if @options['output'] == :stdout
Severity: Minor
Found in lib/uirusu/cli/application.rb - About 4 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_options has 89 lines of code (exceeds 25 allowed). Consider refactoring.
Open

            def parse_options(args)
                begin
                    @options['output']  = :stdout
                    @options['verbose'] = false
                    @options['rescan']  = false
Severity: Major
Found in lib/uirusu/cli/application.rb - About 3 hrs to fix

    Method parse_options has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

                def parse_options(args)
                    begin
                        @options['output']  = :stdout
                        @options['verbose'] = false
                        @options['rescan']  = false
    Severity: Minor
    Found in lib/uirusu/cli/application.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 application.rb has 264 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Uirusu
        module CLI
            class Application
    
                attr_accessor :config
    Severity: Minor
    Found in lib/uirusu/cli/application.rb - About 2 hrs to fix

      Method scan_and_wait has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                  def scan_and_wait(mod, resource, attempts)
                      method = nil
                      retries = attempts
      
                      if mod.name == "Uirusu::VTFile"
      Severity: Major
      Found in lib/uirusu/cli/application.rb - About 2 hrs to fix

        Method main has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    def main(args)
                        parse_options(args)
                        load_config
        
                        if @options['output'] == :stdout
        Severity: Major
        Found in lib/uirusu/cli/application.rb - About 2 hrs to fix

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

                      def load_config file=CONFIG_FILE
          
                          @config = nil
          
                          f = File.expand_path(file)
          Severity: Minor
          Found in lib/uirusu/cli/application.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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                          if @sites != nil
                              @sites.each_with_index do |url, index|
                                  results = scan_and_wait(Uirusu::VTUrl, url, 5)
                                  result = Uirusu::VTResult.new(results[0], results[1])
                                  print result.send output_method if result != nil
          Severity: Minor
          Found in lib/uirusu/cli/application.rb and 1 other location - About 55 mins to fix
          lib/uirusu/cli/application.rb on lines 352..357

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 44.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                          if @uploads != nil
                              @uploads.each_with_index do |upload, index|
                                  results = scan_and_wait(Uirusu::VTFile, upload, 5)
                                  result = Uirusu::VTResult.new(results[0], results[1])
                                  print result.send output_method if result != nil
          Severity: Minor
          Found in lib/uirusu/cli/application.rb and 1 other location - About 55 mins to fix
          lib/uirusu/cli/application.rb on lines 343..348

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 44.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                                  opt.on('-f FILE', '--search-hash-file FILE', 'Searches each hash in a file of hashes on virustotal.com') do |file|
                                      if File.exist?(file)
                                          puts "[+] Adding file #{file}" if @options['verbose']
                                          @files_of_hashes.push(file)
                                      else
          Severity: Minor
          Found in lib/uirusu/cli/application.rb and 1 other location - About 20 mins to fix
          lib/uirusu/cli/application.rb on lines 73..78

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 28.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                                  opt.on('-u FILE', '--upload-file FILE', 'Uploads a file to virustotal.com for analysis') do |file|
                                      if File.exist?(file)
                                          puts "[+] Adding file #{file}" if @options['verbose']
                                          @uploads.push(file)
                                      else
          Severity: Minor
          Found in lib/uirusu/cli/application.rb and 1 other location - About 20 mins to fix
          lib/uirusu/cli/application.rb on lines 64..69

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 28.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          There are no issues that match your filters.

          Category
          Status