wikimedia/wikimedia-fundraising-tools

View on GitHub

Showing 78 of 108 total issues

Function main has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

def main():
    # === Extract options ===
    parser = OptionParser(usage="usage: %prog [options] <timeColumn> <timeInterval> <groupByColumn> ...")
    parser.add_option(
        '-p', '--pivot', dest='pivot', action='store_true', default=False,
Severity: Minor
Found in SquidRipper/aggByTime.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

Function parse_line has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_line(self, row):
        # Drop all rows in non-successful status
        if row['Transactional Status'] != 'S':
            return

Severity: Minor
Found in audit/paypal/TrrFile.py - About 5 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 geonames_updater.py has 328 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/python3.5

from configparser import ConfigParser
from optparse import OptionParser
import dateutil.parser
Severity: Minor
Found in GeonameUpdater/geonames_updater.py - About 3 hrs to fix

    Function read has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    def read(path, version, callback, column_headers, encoding):
        # Coerce to a list
        if not hasattr(version, 'extend'):
            version = [version]
    
    
    Severity: Minor
    Found in audit/paypal/ppreport.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 parseSearchResponse has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        public function parseSearchResponse ( $xml_response ) {
            $currency = CurrencyConversion::init();
            $country_list = CountryCodeConversion::init();
    
            $response = $this->getMetadataRequest();
    Severity: Minor
    Found in audit/payflow/PayflowSearch.php - 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 PayflowReports.php has 298 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php error_reporting (E_ALL);
    
    /*
     * Base class for a returned Payflow Report. This class is used by all others to access Payflow report data.
     *
    Severity: Minor
    Found in audit/payflow/PayflowReports.php - About 3 hrs to fix

      Function update_gdoc_results has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

      def update_gdoc_results(doc=None, results=[]):
          log.info("Updating results in {url}".format(url=doc))
          doc = Spreadsheet(doc=doc)
          existing = list(doc.get_all_rows())
      
      
      Severity: Minor
      Found in fundraising_ab_tests/results_gdoc.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

      Method parseSearchResponse has 69 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function parseSearchResponse ( $xml_response ) {
              $currency = CurrencyConversion::init();
              $country_list = CountryCodeConversion::init();
      
              $response = $this->getMetadataRequest();
      Severity: Major
      Found in audit/payflow/PayflowSearch.php - About 2 hrs to fix

        Function pivotDataByYear has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

        def pivotDataByYear(stats):
            """
            Transformation of the statistical data -- grouping reports by date
        
            Returns ((list of years), {report: {date: [year data]}})
        Severity: Minor
        Found in FundraiserStatisticsGen/fundstatgen.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

        File PayflowSearch.php has 281 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php error_reporting (E_ALL);
        
        require_once( 'PayflowReports.php' );
        
        
        
        Severity: Minor
        Found in audit/payflow/PayflowSearch.php - About 2 hrs to fix

          Function parseCLDR has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

          def parseCLDR(cldr_path):
              """Parse CLDR XML files into currency and locale data
              Returns a set of: (
                  cldr date
                  {currencyIso: {digits, rounding}},
          Severity: Minor
          Found in CldrParser/CldrParser.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

          File stats_abba.py has 256 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # From: http://github.com/thumbtack/abba/python/abba/stats.py, commit 0a7fcda0
          # Copyright (c) 2012 Thumbtack, Inc.
          
          import collections
          import math
          Severity: Minor
          Found in stats/stats_abba.py - About 2 hrs to fix

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

                def execute_paged(self, query, pageIndex, pageSize=1000, dir='ASC'):
                    """ Execute a paged query. This will yield a dictionary of the results
                    until there are no more results to yield. The pageIndex will be added
                    to the order by automatically. If the Query already has a limit, it will
                    be respected (only that many rows will be returned.)
            Severity: Minor
            Found in database/db.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 __init__ has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                def __init__(self, label=None, type="", campaign=None, banners=None, start=None, end=None, disabled=False, **ignore):
                    config = get_config()
                    for key in config.ignored_columns:
                        if key in ignore:
                            ignore.pop(key)
            Severity: Minor
            Found in fundraising_ab_tests/fundraising_experiment.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 curl_download has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

            function curl_download( $url, $cert, $vars = NULL ) {
                $ch = curl_init();
                curl_setopt($ch, CURLOPT_URL, $url);
                curl_setopt($ch, CURLOPT_HEADER, 0); 
                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
            Severity: Minor
            Found in Paypal_refunder/go.php - 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 parse_line has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                def parse_line(self, row):
                    required_fields = [
                        "Period 3 Amount",
                        "Subscription Currency",
                        "Subscription ID",
            Severity: Minor
            Found in audit/paypal/SarFile.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

            Method runReport has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function runReport() {
                    $xml = $this->runReportRequest();
                    $request = $this->createRequest( $xml );
            
                    $rc = $this->sendRequest( $request );
            Severity: Minor
            Found in audit/payflow/PayflowReports.php - About 1 hr to fix

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

                  public function runAudit( $begin, $end ) {
                      $report = new CustomReport( array ( $begin . ' 00:00:00', $end . ' 23:59:59') );
                      if ( $report->runReport()) {
                          $results = $report->getResults();           
                      } else {
              Severity: Minor
              Found in audit/payflow/PayflowAudit.php - 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 begin has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

              def begin(filename=None, failopen=False):
                  if not filename:
                      unique = os.environ['LOGNAME']
                      cmd = os.path.basename(sys.argv[0])
                      filename = "/tmp/%s-%s.lock" % (unique, cmd)
              Severity: Minor
              Found in process/lock.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 extractNumericLocale has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

              def extractNumericLocale(locale, pPattern, nPattern=None):
                  """Extract grouping char, decimal char, digit grouping, positive, and negative format strings from a pattern
                  pPattern -- the positive pattern
                  nPattern -- the negative pattern if given
                  """
              Severity: Minor
              Found in CldrParser/CldrParser.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