wikimedia/wikimedia-fundraising-tools

View on GitHub

Showing 108 of 108 total issues

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

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

        def __init__(self, path):
            self.path = path
            self.config = process.globals.get_config()
            self.crm = civicrm.civicrm.Civicrm(self.config.civicrm_db)
    Severity: Major
    Found in audit/paypal/TrrFile.py and 1 other location - About 1 hr to fix
    audit/paypal/SarFile.py on lines 54..57

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

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

        def __init__(self, path):
            self.path = path
            self.config = process.globals.get_config()
            self.crm = civicrm.civicrm.Civicrm(self.config.civicrm_db)
    Severity: Major
    Found in audit/paypal/SarFile.py and 1 other location - About 1 hr to fix
    audit/paypal/TrrFile.py on lines 102..105

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

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

    Method parseReportResponse has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function parseReportResponse ( $xml_response ) {
            $statusCode = $xml_response->runReportResponse->statusCode;
    
            switch ( $statusCode ) {
                case 1: // Created
    Severity: Minor
    Found in audit/payflow/PayflowReports.php - About 1 hr to fix

      Method curl_download has 39 lines of code (exceeds 25 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 1 hr to fix

        Method runSearch has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

          Function fetch has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          def fetch():
              out = csv.DictWriter(sys.stdout, [
                  'campaign',
                  'banner',
                  'start',
          Severity: Minor
          Found in live_analysis/dump_tests.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 should_send has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def should_send(self, out, queue_name, row, event_type):
                  if not queue_name:
                      log.info("-Unknown\t{id}\t{date}\t(Type {type})".format(id=out['gateway_txn_id'], date=out['date'], type=event_type))
                      return False
          
          
          Severity: Minor
          Found in audit/paypal/TrrFile.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 update_gdoc_spec has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          def update_gdoc_spec(doc=None, spec=None):
              log.info("Updating test specs with latest CentralNotice changes... {url}".format(url=doc))
          
              # FIXME: currently, the spec must have been read with read_gdoc_spec in order to get row numbers
              if not spec:
          Severity: Minor
          Found in fundraising_ab_tests/spec_gdoc.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

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

                  if 'enabled' in entry['added'] or entry['begin']['enabled'] == 1:
                      return True
          Severity: Major
          Found in fundraising_ab_tests/campaign_log.py and 1 other location - About 1 hr to fix
          live_analysis/dump_tests.py on lines 21..22

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

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

              if 'enabled' in entry['added'] or entry['begin']['enabled'] == 1:
                  return True
          Severity: Major
          Found in live_analysis/dump_tests.py and 1 other location - About 1 hr to fix
          fundraising_ab_tests/campaign_log.py on lines 50..51

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

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

                  if (edge == 'begin' and 'enabled' in entry['added'] and int(entry['added']['enabled'])) or (edge == 'end' and 'enabled' in entry['removed'] and int(entry['removed']['enabled'])):
          Severity: Major
          Found in fundraising_ab_tests/campaign_log.py and 1 other location - About 1 hr to fix
          fundraising_ab_tests/campaign_log.py on lines 14..14

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

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

                          log.info("-Unknown\t{id}\t{date}\t(Refundish type {type})".format(id=out['gateway_txn_id'], date=out['date'], type=row['Transaction Event Code']))
          Severity: Major
          Found in audit/paypal/TrrFile.py and 1 other location - About 1 hr to fix
          audit/paypal/TrrFile.py on lines 181..181

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

          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 import_geonames_file has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          def import_geonames_file(filename):
              global _geonamesDB
          
              # === Prepare things ===
              try:
          Severity: Minor
          Found in GeonameUpdater/geonames_updater.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