Showing 66 of 1,425 total issues

Function run_client has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

def run_client(ccp):
    '''
    Run the client according to the configuration in the ConfigParser
    object.
    '''
Severity: Minor
Found in bin/client.py - 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

Function scan_dir has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
Open

def scan_dir(parser, dirpath, reparse, expr, apel_db, processed):
    '''
    Check all files in a directory and parse them if:
     - the names match the regular expression
     - the file is not already in the list of processed files
Severity: Minor
Found in bin/parser.py - 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

Function _check_fields has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
Open

    def _check_fields(self):

        # shorthand
        contents = self._record_content

Severity: Minor
Found in apel/db/records/record.py - About 6 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 mysql.py has 405 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'''
   Copyright (C) 2011,2012 STFC

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
Severity: Minor
Found in apel/db/backends/mysql.py - About 5 hrs to fix

    Function fetch_specint has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

    def fetch_specint(site, host='lcg-bdii.egi.eu', port=2170):
        '''
        Imports benchmark data from LDAP. Current implementation
        is able to fetch data according to way described here:
    
    
    Severity: Minor
    Found in apel/ldap/query.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 handle_parsing has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

    def handle_parsing(log_type, apel_db, cp):
        '''
        Create the appropriate parser, and scan the configured directory
        for log files, parsing them.
    
    
    Severity: Minor
    Found in bin/parser.py - About 3 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 parser.py has 316 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #!/usr/bin/env python
    
    #   Copyright (C) 2012 STFC
    #
    #   Licensed under the Apache License, Version 2.0 (the "License");
    Severity: Minor
    Found in bin/parser.py - About 3 hrs to fix

      Function copy_records has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

      def copy_records(db1, db2, cutoff):
          '''
          Copy all records from the LcgRecords table in db1 to the JobRecords
          table in db2 whose EndTime is greater than the cutoff datetime.
          '''
      Severity: Minor
      Found in scripts/migrate_apel.py - About 3 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 checked has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          def checked(self, name, value):
              '''
              Returns value converted to correct type if this is possible.
              Otherwise it raises an error.
              '''
      Severity: Minor
      Found in apel/db/records/record.py - About 3 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 parse_file has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      def parse_file(parser, apel_db, fp, replace):
          '''
          Parses file from blah/batch system
      
          @param parser: parser object of correct type
      Severity: Minor
      Found in bin/parser.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 get_ur has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def get_ur(self, withhold_dns=False):
              '''
              Returns the JobRecord in CAR format. See
              https://twiki.cern.ch/twiki/bin/view/EMI/ComputeAccounting
      
      
      Severity: Major
      Found in apel/db/records/job.py - About 2 hrs to fix

        File record.py has 265 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        '''
           Copyright (C) 2011, 2012 STFC
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
        Severity: Minor
        Found in apel/db/records/record.py - About 2 hrs to fix

          Function _load_multipliers has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              def _load_multipliers(self):
                  '''
                  Returns a dictionary {hostname: {cputmult: <value>, wallmult: <value>}}.
          
                  Hosts with no cputmult/wallmult definitions are ignored.
          Severity: Minor
          Found in apel/parsers/sge.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 get_ur has 51 lines of code (exceeds 25 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: Major
          Found in apel/db/records/normalised_summary.py - About 2 hrs to fix

            File client.py has 251 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            #!/usr/bin/env python
            
            #   Copyright (C) 2012 STFC
            #
            #   Licensed under the Apache License, Version 2.0 (the "License");
            Severity: Minor
            Found in bin/client.py - About 2 hrs to fix

              Function get_ur has 49 lines of code (exceeds 25 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 1 hr to fix

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

                def runprocess(config_file, log_config_file):
                    '''Get DNs both from the URL and the additional file.'''
                    cfg = get_config(config_file)
                
                    log = logging.getLogger('auth')
                Severity: Minor
                Found in bin/retrieve_dns.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 parse has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                    def parse(self, line):
                
                        # correct handling of double quotes
                        # expression <condition and expr1 or expr2> in Python
                        # means the same as <condition ? expr1 : expr2> in C
                Severity: Minor
                Found in apel/parsers/lsf.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 _get_where_helper has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _get_where_helper(self):
                        '''
                        Private function which uses reflection to get information
                        about fields and relations.
                
                
                Severity: Minor
                Found in apel/db/apeldb.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 runprocess has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                def runprocess(db_config_file, config_file, log_config_file):
                    '''Parse the configuration file, connect to the database and run the
                       summarising process.'''
                
                    # Store start time to log how long the summarising process takes
                Severity: Minor
                Found in bin/summariser.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

                Severity
                Category
                Status
                Source
                Language