hackedteam/vector-edk

View on GitHub
vector-uefi/fd/efi/StdLib/lib/python.27/ftplib.py

Summary

Maintainability
F
2 mos
Test Coverage

File ftplib.py has 845 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""An FTP client class and some helper functions.

Based on RFC 959: File Transfer Protocol (FTP), by J. Postel and J. Reynolds

Example:
Severity: Major
Found in vector-uefi/fd/efi/StdLib/lib/python.27/ftplib.py - About 2 days to fix

    FTP has 38 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class FTP:
    
        '''An FTP client class.
    
        To create a connection, call the class using these arguments:
    Severity: Minor
    Found in vector-uefi/fd/efi/StdLib/lib/python.27/ftplib.py - About 5 hrs to fix

      Function __init__ has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(self, filename=None):
              if filename is None:
                  if "HOME" in os.environ:
                      filename = os.path.join(os.environ["HOME"],
                                              ".netrc")
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/ftplib.py - 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

      Function ntransfercmd has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def ntransfercmd(self, cmd, rest=None):
              """Initiate a transfer over the data connection.
      
              If the transfer is active, send a port command and the
              transfer command, and accept the connection.  If the server is
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/ftplib.py - 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

      Function test has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      def test():
          '''Test program.
          Usage: ftp [-d] [-r[file]] host [-l[dir]] [-d[dir]] [-p] [file] ...
      
          -d dir
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/ftplib.py - 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

      Function storlines has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

              def storlines(self, cmd, fp, callback=None):
                  self.voidcmd('TYPE A')
                  conn = self.transfercmd(cmd)
                  try:
                      while 1:
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/ftplib.py - 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

      Function makeport has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def makeport(self):
              '''Create a new socket and send a PORT command for it.'''
              msg = "getaddrinfo returns an empty list"
              sock = None
              for res in socket.getaddrinfo(None, 0, self.af, socket.SOCK_STREAM, 0, socket.AI_PASSIVE):
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/ftplib.py - 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

      Function storlines has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def storlines(self, cmd, fp, callback=None):
              """Store a file in line mode.  A new port is created for you.
      
              Args:
                cmd: A STOR command.
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/ftplib.py - 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

      Function retrlines has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

              def retrlines(self, cmd, callback = None):
                  if callback is None: callback = print_line
                  resp = self.sendcmd('TYPE A')
                  conn = self.transfercmd(cmd)
                  fp = conn.makefile('rb')
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/ftplib.py - 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

      Function retrlines has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def retrlines(self, cmd, callback = None):
              """Retrieve data in line mode.  A new port is created for you.
      
              Args:
                cmd: A RETR, LIST, NLST, or MLSD command.
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/ftplib.py - 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

      Function parse257 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def parse257(resp):
          '''Parse the '257' response for a MKD or PWD request.
          This is a response to a MKD or PWD request: a directory name.
          Returns the directoryname in the 257 reply.'''
      
      Severity: Minor
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/ftplib.py - 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

      Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              def __init__(self, host='', user='', passwd='', acct='', keyfile=None,
      Severity: Major
      Found in vector-uefi/fd/efi/StdLib/lib/python.27/ftplib.py - About 50 mins to fix

        Consider simplifying this complex logical expression.
        Open

                        if w1 == 'default':
                            default = 1
                        elif w1 == 'machine' and w2:
                            host = w2.lower()
                            i = i + 1
        Severity: Major
        Found in vector-uefi/fd/efi/StdLib/lib/python.27/ftplib.py - About 40 mins to fix

          Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(self, host='', user='', passwd='', acct='',
          Severity: Minor
          Found in vector-uefi/fd/efi/StdLib/lib/python.27/ftplib.py - About 35 mins to fix

            Function ftpcp has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def ftpcp(source, sourcename, target, targetname = '', type = 'I'):
            Severity: Minor
            Found in vector-uefi/fd/efi/StdLib/lib/python.27/ftplib.py - About 35 mins to fix

              Function storbinary has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      def storbinary(self, cmd, fp, blocksize=8192, callback=None, rest=None):
              Severity: Minor
              Found in vector-uefi/fd/efi/StdLib/lib/python.27/ftplib.py - About 35 mins to fix

                Function storbinary has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def storbinary(self, cmd, fp, blocksize=8192, callback=None, rest=None):
                Severity: Minor
                Found in vector-uefi/fd/efi/StdLib/lib/python.27/ftplib.py - About 35 mins to fix

                  Function login has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def login(self, user = '', passwd = '', acct = ''):
                          '''Login, default anonymous.'''
                          if not user: user = 'anonymous'
                          if not passwd: passwd = ''
                          if not acct: acct = ''
                  Severity: Minor
                  Found in vector-uefi/fd/efi/StdLib/lib/python.27/ftplib.py - 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

                  Function getmultiline has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def getmultiline(self):
                          line = self.getline()
                          if line[3:4] == '-':
                              code = line[:3]
                              while 1:
                  Severity: Minor
                  Found in vector-uefi/fd/efi/StdLib/lib/python.27/ftplib.py - 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

                  Function cwd has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def cwd(self, dirname):
                          '''Change to a directory.'''
                          if dirname == '..':
                              try:
                                  return self.voidcmd('CDUP')
                  Severity: Minor
                  Found in vector-uefi/fd/efi/StdLib/lib/python.27/ftplib.py - 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

                  Function storbinary has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                          def storbinary(self, cmd, fp, blocksize=8192, callback=None, rest=None):
                              self.voidcmd('TYPE I')
                              conn = self.transfercmd(cmd, rest)
                              try:
                                  while 1:
                  Severity: Minor
                  Found in vector-uefi/fd/efi/StdLib/lib/python.27/ftplib.py - 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

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

                  Severity: Major
                  Found in vector-uefi/fd/efi/StdLib/lib/python.27/ftplib.py and 1 other location - About 2 mos to fix
                  AppPkg/Applications/Python/Python-2.7.2/Lib/ftplib.py on lines 0..1036

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

                  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