18F/forecast

View on GitHub

Showing 8 of 133 total issues

File load_opportunities.py has 329 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import os
import csv
from datetime import date
from decimal import Decimal, InvalidOperation
import re

    File models.py has 321 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from django.db import models
    from django.contrib.auth.models import User
    from django.core.validators import MaxValueValidator, RegexValidator
    
    from localflavor.us.models import USStateField, PhoneNumberField
    Severity: Minor
    Found in forecast-admin/forecast/opportunities/models.py - About 3 hrs to fix

      Function make_opportunity has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          def make_opportunity(cls, row, agency='GSA'):
              if agency == "GSA":
                  office = cls.insert_office(row[0], row[1])
      
                  adv = cls.parse_advisor(row[23])

      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 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse_file(self, filename, strict=False, agency='GSA'):
              with open(filename, 'rU') as f:
                  reader = csv.reader(f)
      
                  for _ in range(self.header_rows):

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

          def parse_fiscal_dates(s):
              try:
                  split = s.split("-")
                  year = split[0][3:]
                  original_quarter = split[1]

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

          def parse_fiscal_quarter_only(s):
              q = re.search(r"(\d)", s)
              if q:
                  n = q.group(1)
                  if n == "1":

      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

      Avoid too many return statements within this function.
      Open

                  return opportunity

        Avoid too many return statements within this function.
        Open

                    return opportunity
          Severity
          Category
          Status
          Source
          Language