rapid7/metasploit-framework

View on GitHub
lib/rex/post/smb/ui/console/command_dispatcher/shares.rb

Summary

Maintainability
F
3 days
Test Coverage

File shares.rb has 483 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'pathname'
require 'rex/post/file'
require 'filesize'

module Rex
Severity: Minor
Found in lib/rex/post/smb/ui/console/command_dispatcher/shares.rb - About 7 hrs to fix

    Class Shares has 31 methods (exceeds 20 allowed). Consider refactoring.
    Open

            class Console::CommandDispatcher::Shares
    
              include Rex::Post::SMB::Ui::Console::CommandDispatcher
    
              #
    Severity: Minor
    Found in lib/rex/post/smb/ui/console/command_dispatcher/shares.rb - About 3 hrs to fix

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

                def cmd_shares(*args)
                  if args.include?('-h') || args.include?('--help')
                    cmd_shares_help
                    return
                  end
      Severity: Minor
      Found in lib/rex/post/smb/ui/console/command_dispatcher/shares.rb - About 1 hr to fix

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

                  def cmd_shares(*args)
                    if args.include?('-h') || args.include?('--help')
                      cmd_shares_help
                      return
                    end
        Severity: Minor
        Found in lib/rex/post/smb/ui/console/command_dispatcher/shares.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 cmd_ls has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                  def cmd_ls(*args)
                    if args.include?('-h') || args.include?('--help')
                      cmd_ls_help
                      return
                    end
        Severity: Minor
        Found in lib/rex/post/smb/ui/console/command_dispatcher/shares.rb - About 1 hr to fix

          Method cmd_upload has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                    def cmd_upload(*args)
                      if args.include?('-h') || args.include?('--help')
                        cmd_upload_help
                        return
                      end
          Severity: Minor
          Found in lib/rex/post/smb/ui/console/command_dispatcher/shares.rb - About 1 hr to fix

            Method cmd_rmdir has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                      def cmd_rmdir(*args)
                        if args.include?('-h') || args.include?('--help')
                          cmd_rmdir_help
                          return
                        end
            Severity: Minor
            Found in lib/rex/post/smb/ui/console/command_dispatcher/shares.rb - About 1 hr to fix

              Method cmd_download has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                        def cmd_download(*args)
                          if args.include?('-h') || args.include?('--help')
                            cmd_download_help
                            return
                          end
              Severity: Minor
              Found in lib/rex/post/smb/ui/console/command_dispatcher/shares.rb - About 1 hr to fix

                Method cmd_cd has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                          def cmd_cd(*args)
                            if args.include?('-h') || args.include?('--help') || args.length != 1
                              cmd_cd_help
                              return
                            end
                Severity: Minor
                Found in lib/rex/post/smb/ui/console/command_dispatcher/shares.rb - About 1 hr to fix

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

                            def cmd_rmdir(*args)
                              if args.include?('-h') || args.include?('--help')
                                cmd_rmdir_help
                                return
                              end
                  Severity: Minor
                  Found in lib/rex/post/smb/ui/console/command_dispatcher/shares.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 cmd_ls has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                            def cmd_ls(*args)
                              if args.include?('-h') || args.include?('--help')
                                cmd_ls_help
                                return
                              end
                  Severity: Minor
                  Found in lib/rex/post/smb/ui/console/command_dispatcher/shares.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 cmd_download has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                            def cmd_download(*args)
                              if args.include?('-h') || args.include?('--help')
                                cmd_download_help
                                return
                              end
                  Severity: Minor
                  Found in lib/rex/post/smb/ui/console/command_dispatcher/shares.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 cmd_upload has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                            def cmd_upload(*args)
                              if args.include?('-h') || args.include?('--help')
                                cmd_upload_help
                                return
                              end
                  Severity: Minor
                  Found in lib/rex/post/smb/ui/console/command_dispatcher/shares.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 cmd_cd has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                            def cmd_cd(*args)
                              if args.include?('-h') || args.include?('--help') || args.length != 1
                                cmd_cd_help
                                return
                              end
                  Severity: Minor
                  Found in lib/rex/post/smb/ui/console/command_dispatcher/shares.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 cmd_mkdir has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                            def cmd_mkdir(*args)
                              if args.include?('-h') || args.include?('--help')
                                cmd_mkdir_help
                                return
                              end
                  Severity: Minor
                  Found in lib/rex/post/smb/ui/console/command_dispatcher/shares.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 cmd_cat has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                            def cmd_cat(*args)
                              if args.include?('-h') || args.include?('--help') || args.length != 1
                                cmd_cd_help
                                return
                              end
                  Severity: Minor
                  Found in lib/rex/post/smb/ui/console/command_dispatcher/shares.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 download_file has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                            def download_file(dest_file, src_file)
                              buf_size = 8 * 1024 * 1024
                              src_fd = simple_client.open(src_file, 'o')
                              # Make the destination path if necessary
                              dir = ::File.dirname(dest_file)
                  Severity: Minor
                  Found in lib/rex/post/smb/ui/console/command_dispatcher/shares.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 cmd_pwd has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                            def cmd_pwd(*args)
                              if args.include?('-h') || args.include?('--help')
                                cmd_pwd_help
                                return
                              end
                  Severity: Minor
                  Found in lib/rex/post/smb/ui/console/command_dispatcher/shares.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

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

                            def cmd_upload(*args)
                              if args.include?('-h') || args.include?('--help')
                                cmd_upload_help
                                return
                              end
                  Severity: Major
                  Found in lib/rex/post/smb/ui/console/command_dispatcher/shares.rb and 1 other location - About 2 hrs to fix
                  lib/rex/post/smb/ui/console/command_dispatcher/shares.rb on lines 417..451

                  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 80.

                  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

                            def cmd_download(*args)
                              if args.include?('-h') || args.include?('--help')
                                cmd_download_help
                                return
                              end
                  Severity: Major
                  Found in lib/rex/post/smb/ui/console/command_dispatcher/shares.rb and 1 other location - About 2 hrs to fix
                  lib/rex/post/smb/ui/console/command_dispatcher/shares.rb on lines 369..403

                  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 80.

                  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