File product.py
has 784 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
from datetime import date, timedelta
from decimal import Decimal
from django.db import models
Product
has 33 functions (exceeds 20 allowed). Consider refactoring. Open
class Product(BaseProduct, AditionalCostsMixin):
hr_id = models.CharField(max_length=12, unique=True, null=True)
float_id = models.CharField(max_length=128, unique=True)
is_billable = models.BooleanField(default=True)
area = models.ForeignKey('Area', related_name='products',
Function stats_in_time_frames
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def stats_in_time_frames(self, start_date, end_date, freq,
calculation_start_date=None):
"""
cumulative stats of time frames sliced by freq
:param start_date: start date of time window, a date object
- Read upRead up
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
Consider simplifying this complex logical expression. Open
if self.end_date and today >= self.end_date:
return 'Ended'
elif self.live_date and today >= self.live_date:
return 'Live'
elif self.beta_date and today >= self.beta_date:
Function people_costs
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def people_costs(self, start_date, end_date, contractor_only=False,
Function people_costs
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def people_costs(self, start_date, end_date, contractor_only=False,
Function phase
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def phase(self):
today = date.today()
if self.end_date and today >= self.end_date:
return 'Ended'
elif self.live_date and today >= self.live_date:
- Read upRead up
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 last_date
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def last_date(self):
"""
default end date is the date when the last spend occurs or
the last budget allocated to the product or the specified end date
it is the greatest of these dates in the product:
- Read upRead up
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 'Not Defined'
Avoid too many return
statements within this function. Open
return 'Discovery'