wikimedia/wikimedia-fundraising-tools

View on GitHub
FundraiserStatisticsGen/fundstatgen.py

Summary

Maintainability
B
5 hrs
Test Coverage

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

Function main has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def main():
    # Extract any command line options
    parser = OptionParser(usage="usage: %prog [options] <working directory>")
    parser.add_option("-c", "--config", dest='configFile', default=None, help='Path to configuration file')
    (options, args) = parser.parse_args()
Severity: Minor
Found in FundraiserStatisticsGen/fundstatgen.py - About 1 hr to fix

    Function createSingleOutFile has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def createSingleOutFile(stats, firstcols, basefilename, 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: Minor
    Found in FundraiserStatisticsGen/fundstatgen.py - About 45 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 getPerCampaignData has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def getPerCampaignData(host, port, username, password, database):
    Severity: Minor
    Found in FundraiserStatisticsGen/fundstatgen.py - About 35 mins to fix

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

      def getPerYearData(host, port, username, password, database):
      Severity: Minor
      Found in FundraiserStatisticsGen/fundstatgen.py - About 35 mins to fix

        There are no issues that match your filters.

        Category
        Status