Showing 1,557 of 1,564 total issues

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

    def parse(self, line):
        """Parse single line from accounting log file."""
        # Some sites will use TotalCPU rather than CPUTimeRAW

        # sacct -P -n --format=JobID,JobName,User,Group,Start,End,Elapsed,
Severity: Minor
Found in apel/parsers/slurm.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 get_ur has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def get_ur(self):
        '''
        Returns the NormalisedSummaryRecord in AUR format. See
        https://twiki.cern.ch/twiki/bin/view/EMI/ComputeAccounting

Severity: Minor
Found in apel/db/records/normalised_summary.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 _check_fields has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def _check_fields(self):
        '''
        Add extra checks to those made in every record.
        '''
        # First, call the parent's version.
Severity: Minor
Found in apel/db/records/job.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 _write_messages has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def _write_messages(self, record_type, table_name, query, ur):
        '''
        Write messsages for all the records found in the specified table,
        according to the logic contained in the query object.
        '''
Severity: Minor
Found in apel/db/unloader.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 shutdown has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def shutdown(self):
        """
        Unlock current messsage queue element and remove pidfile.
        """
        # Check if self.current_msg is assigned as it may not have been before
Severity: Minor
Found in apel/db/loader/loader.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 get_ur has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def get_ur(self):
        '''
        Returns the SummaryRecord in AUR format.  See
        https://twiki.cern.ch/twiki/bin/view/EMI/ComputeAccounting

Severity: Minor
Found in apel/db/records/summary.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 retrieve_rmem has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def retrieve_rmem(self, nodes):
        '''
        Given all the nodes from the XML document, retrieve the appropriate values
        for virtual and physical memory.

Severity: Minor
Found in apel/db/loader/car_parser.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

Avoid too many return statements within this function.
Open

                    return datetime.utcfromtimestamp(value)
Severity: Major
Found in apel/db/records/record.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                            return dt
    Severity: Major
    Found in apel/db/records/record.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return RECORDS_PER_MESSAGE_DEFAULT
      Severity: Major
      Found in bin/dbunloader.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                        return value
        Severity: Major
        Found in apel/db/records/record.py - About 30 mins to fix

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

              def update_spec(self, site, ce, spec_level_type, spec_level):
                  '''
                  This method compares the existing data from database to given values
                  and updates the SpecRecords table if it is neccessary.
                  '''
          Severity: Minor
          Found in apel/db/backends/mysql.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

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

          def check_empty_dirs(q):
              empty_dirs = []
              path = q.path
              print("Checking path %s " % path)
              for item in os.listdir(path):
          Severity: Minor
          Found in scripts/msg_status.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

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

              def _get_base_query(self, record_type):
                  '''
                  Set up a query object containing the logic which is common for
                  all users of this DbUnloader.
                  '''
          Severity: Minor
          Found in apel/db/unloader.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

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

              def _normalise_memory(self, mem):
                  """Strip unit prefix and return memory size as int in KB."""
          
                  # Accepted prefixes and their power of 1024 relative to KB.
                  unit_prefixes = {'K': 0, 'M': 1, 'G': 2, 'T': 3, 'P': 4}
          Severity: Minor
          Found in apel/parsers/slurm.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

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

          def runprocess(db_config_file, config_file, log_config_file):
              '''Parse the configuration file and start the loader.'''
          
              # Read configuration from file
              cp = ConfigParser.ConfigParser()
          Severity: Minor
          Found in bin/dbloader.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

          Fenced code blocks should be surrounded by blank lines
          Open

            ```
          Severity: Info
          Found in server_upgrade.md by markdownlint

          MD031 - Fenced code blocks should be surrounded by blank lines

          Tags: code, blank_lines

          Aliases: blanks-around-fences

          This rule is triggered when fenced code blocks are either not preceded or not followed by a blank line:

          Some text
          ```
          Code block
          ```
          
          ```
          Another code block
          ```
          Some more text

          To fix this, ensure that all fenced code blocks have a blank line both before and after (except where the block is at the beginning or end of the document):

          Some text
          
          ```
          Code block
          ```
          
          ```
          Another code block
          ```
          
          Some more text

          Rationale: Aside from aesthetic reasons, some parsers, including kramdown, will not parse fenced code blocks that don't have blank lines before and after them.

          Line too long (111 > 79 characters)
          Open

            startTime DATETIME, endTime DATETIME, infrastructureDescription VARCHAR(100), infrastructureType VARCHAR(20),
          Severity: Minor
          Found in scripts/migrate_apel.py by pep8

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.

          Line too long (92 > 79 characters)
          Open

              sys.stdout.write("\n    from %s:%s to %s:%s ...\n\n" % (host1, dbname1, host2, dbname2))
          Severity: Minor
          Found in scripts/migrate_apel.py by pep8

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.

          Continuation line under-indented for visual indent
          Open

                                        ldap.SCOPE_SUBTREE,
          Severity: Minor
          Found in apel/ldap/query.py by pep8

          Continuation lines indentation.

          Continuation lines should align wrapped elements either vertically
          using Python's implicit line joining inside parentheses, brackets
          and braces, or using a hanging indent.
          
          When using a hanging indent these considerations should be applied:
          - there should be no arguments on the first line, and
          - further indentation should be used to clearly distinguish itself
            as a continuation line.
          
          Okay: a = (\n)
          E123: a = (\n    )
          
          Okay: a = (\n    42)
          E121: a = (\n   42)
          E122: a = (\n42)
          E123: a = (\n    42\n    )
          E124: a = (24,\n     42\n)
          E125: if (\n    b):\n    pass
          E126: a = (\n        42)
          E127: a = (24,\n      42)
          E128: a = (24,\n    42)
          E129: if (a or\n    b):\n    pass
          E131: a = (\n    42\n 24)
          Severity
          Category
          Status
          Source
          Language