wikimedia/wikimedia-fundraising-tools

View on GitHub

Showing 108 of 108 total issues

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

def createSingleOutFile(stats, firstcols, filename, colnames=None):
    """
    Creates a single report file from a keyed dict

    stats       must be a dictionary of something list like; if internally it is a dictionary
Severity: Major
Found in FundraiserStatisticsGen/countrygen.py and 2 other locations - About 2 days to fix
FundraiserStatisticsGen/mediumgen.py on lines 81..114
FundraiserStatisticsGen/methodgen.py on lines 79..112

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

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

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

def createSingleOutFile(stats, firstcols, filename, colnames=None):
    """
    Creates a single report file from a keyed dict

    stats       must be a dictionary of something list like; if internally it is a dictionary
Severity: Major
Found in FundraiserStatisticsGen/methodgen.py and 2 other locations - About 2 days to fix
FundraiserStatisticsGen/countrygen.py on lines 126..159
FundraiserStatisticsGen/mediumgen.py on lines 81..114

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

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

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

def createSingleOutFile(stats, firstcols, filename, colnames=None):
    """
    Creates a single report file from a keyed dict

    stats       must be a dictionary of something list like; if internally it is a dictionary
Severity: Major
Found in FundraiserStatisticsGen/mediumgen.py and 2 other locations - About 2 days to fix
FundraiserStatisticsGen/countrygen.py on lines 126..159
FundraiserStatisticsGen/methodgen.py on lines 79..112

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

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

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

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

def export_data(output_path=None):
    config = process.globals.get_config()

    db = DbConnection(**config.silverpop_db)

Severity: Major
Found in silverpop_export/export.py and 3 other locations - About 5 hrs to fix
silverpop_export/export.py on lines 110..119
silverpop_export/export.py on lines 127..136
silverpop_export/export.py on lines 144..153

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

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 4 locations. Consider refactoring.
Open

def export_checksum_email(output_path=None):
    config = process.globals.get_config()

    db = DbConnection(**config.silverpop_db)

Severity: Major
Found in silverpop_export/export.py and 3 other locations - About 5 hrs to fix
silverpop_export/export.py on lines 93..102
silverpop_export/export.py on lines 110..119
silverpop_export/export.py on lines 127..136

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

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 4 locations. Consider refactoring.
Open

def export_matching_gifts(output_path=None):
    config = process.globals.get_config()

    db = DbConnection(**config.silverpop_db)

Severity: Major
Found in silverpop_export/export.py and 3 other locations - About 5 hrs to fix
silverpop_export/export.py on lines 93..102
silverpop_export/export.py on lines 110..119
silverpop_export/export.py on lines 144..153

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

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 4 locations. Consider refactoring.
Open

def export_unsubscribes(output_path=None):
    config = process.globals.get_config()

    db = DbConnection(**config.silverpop_db)

Severity: Major
Found in silverpop_export/export.py and 3 other locations - About 5 hrs to fix
silverpop_export/export.py on lines 93..102
silverpop_export/export.py on lines 127..136
silverpop_export/export.py on lines 144..153

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

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

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

            Severity
            Category
            Status
            Source
            Language