ministryofjustice/moj-product-dashboard

View on GitHub

Showing 94 of 322 total issues

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
Severity: Major
Found in dashboard/apps/dashboard/models/product.py - About 1 day to fix

    File test_product.py has 594 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    from datetime import date, timedelta
    from decimal import Decimal
    
    import pytest
    Severity: Major
    Found in dashboard/apps/dashboard/tests/test_product.py - About 1 day to fix

      Function insert_rows has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
      Open

      def insert_rows(ws, row_idx, cnt, above=False, copy_style=True,
                      fill_formulae=True):  # flake8: noqa  # pragma: no cover
          """Inserts new (empty) rows into worksheet at specified row index.
      
          :param row_idx: Row index specifying where to insert new rows.
      Severity: Minor
      Found in dashboard/apps/reports/forms.py - About 1 day 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 plotCumulativeSpendings has 145 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function plotCumulativeSpendings(product, showBurnDown, startDate, endDate, elem, isSmall) {
        const today = moment().format('YYYY-MM-DD');
        const keyDatesFinancials = product.keyDatesFinancials;
        const keyDates = Object.keys(keyDatesFinancials).sort();
        const pastDates = keyDates.filter(d => d <= today).sort();
      Severity: Major
      Found in dashboard/assets/js/components/cumulative-graph.js - About 5 hrs to fix

        File forms.py has 406 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # -*- coding: utf-8 -*-
        from collections import defaultdict
        import copy
        import os
        from decimal import Decimal
        Severity: Minor
        Found in dashboard/apps/reports/forms.py - About 5 hrs to fix

          File test_task.py has 384 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          from decimal import Decimal
          from datetime import date
          
          from django.test import TestCase
          from model_mommy import mommy
          Severity: Minor
          Found in dashboard/apps/dashboard/tests/test_task.py - About 5 hrs to fix

            File sync.py has 353 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            #!/usr/bin/env python
            # -*- coding: utf-8 -*-
            """
            export from float
            """
            Severity: Minor
            Found in dashboard/apps/dashboard/management/commands/sync.py - About 4 hrs to fix

              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',
              Severity: Minor
              Found in dashboard/apps/dashboard/models/product.py - About 4 hrs to fix

                Function clean_payroll_file has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                Open

                    def clean_payroll_file(self):
                        start, end = self.cleaned_data.get('date_range')
                        if not start or not end:
                            raise ValidationError('No date supplied.')
                
                
                Severity: Minor
                Found in dashboard/apps/reports/forms.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

                File product.js has 317 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import moment from 'moment';
                import React, { Component } from 'react';
                import Plotly from '../libs/plotly-custom';
                
                import { plotCumulativeSpendings } from '../components/cumulative-graph';
                Severity: Minor
                Found in dashboard/assets/js/components/product.js - About 3 hrs to fix

                  Product has 27 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  export class Product {
                    constructor(productJSON) {
                      Object.assign(this, productJSON);
                    }
                  
                  
                  Severity: Minor
                  Found in dashboard/assets/js/libs/models.js - About 3 hrs to fix

                    File models.js has 293 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import 'whatwg-fetch';
                    import moment from 'moment';
                    
                    import { startOfMonth, endOfMonth, thisCalendarYear,
                             thisFinancialYear, thisQuarter, lastCalendarYear,
                    Severity: Minor
                    Found in dashboard/assets/js/libs/models.js - About 3 hrs to fix

                      Function normalMode has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        normalMode() {
                          const product = this.state.product;
                          const editButton = () => {
                            if (product.meta['can_edit']) {
                              return (
                      Severity: Major
                      Found in dashboard/assets/js/containers/product-main.js - About 2 hrs to fix

                        Function timeFrames has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          get timeFrames() {
                            const now = moment();
                            const result = {
                              'entire-time-span': {
                                name: 'Entire product life time',
                        Severity: Major
                        Found in dashboard/assets/js/libs/models.js - About 2 hrs to fix

                          Function plotMonthlySpendings has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export function plotMonthlySpendings(product, startDate, endDate, elem, isSmall) {
                            const monthly = product.monthlyFinancials;
                            const months = Object.keys(monthly).sort()
                              .filter(m => endOfMonth(m) >= startDate && endOfMonth(m) <= endDate);
                          
                          
                          Severity: Major
                          Found in dashboard/assets/js/components/monthly-graph.js - About 2 hrs to fix

                            File cumulative-graph.js has 256 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            import moment from 'moment';
                            
                            import Plotly from '../libs/plotly-custom';
                            import { round, monthRange } from '../libs/utils';
                            
                            
                            Severity: Minor
                            Found in dashboard/assets/js/components/cumulative-graph.js - About 2 hrs to fix

                              Function write has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def write(self, workbook, ws=None):
                                      ws = workbook.get_active_sheet()
                                      product = self.cleaned_data['product']
                                      start_date, end_date = self.cleaned_data['date_range']
                              
                              
                              Severity: Minor
                              Found in dashboard/apps/reports/forms.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 backgroundForPhases has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function backgroundForPhases(product, range, isSmall) {
                                const phases = product.phases;
                                const shapes = [];
                                const annotations = [];
                              
                              
                              Severity: Minor
                              Found in dashboard/assets/js/components/cumulative-graph.js - About 1 hr to fix

                                Function sync_tasks has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                                Open

                                def sync_tasks(start_date, end_date, data_dir):
                                    logging.info('sync tasks')
                                    source = os.path.join(data_dir, 'tasks.json')
                                    with open(source, 'r') as sf:
                                        data = json.loads(sf.read())
                                Severity: Minor
                                Found in dashboard/apps/dashboard/management/commands/sync.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 additional_rate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    def additional_rate(self, start_date, end_date, name=None,
                                                        predict_based_on=None):
                                        costs = self.get_costs_between(start_date, end_date, name=name)
                                        if not self.is_contractor and not costs:
                                            # If additional costs haven't been added for the month then
                                Severity: Minor
                                Found in dashboard/apps/dashboard/models/person.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