Showing 176 of 177 total issues

Function make_contract has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

    def make_contract(cls, line, upload_source=None):
        if line[0]:
            # create contract record, unique to vendor, labor cat
            idv_piid = line[11]
            vendor_name = line[10]
Severity: Minor
Found in contracts/loaders/region_10.py - About 5 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

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

def find_header_row(sheet, row_threshold=50):
    first_col_heading = COLUMN_TITLES['sin']
    row_limit = min(sheet.nrows, row_threshold)

    for rx in range(row_limit):
Severity: Major
Found in data_capture/schedules/s736.py and 1 other location - About 5 hrs to fix
data_capture/schedules/s70.py on lines 87..97

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

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 find_header_row(sheet, row_threshold=50):
    first_col_heading = COLUMN_TITLES['sin']
    row_limit = min(sheet.nrows, row_threshold)

    for rx in range(row_limit):
Severity: Major
Found in data_capture/schedules/s70.py and 1 other location - About 5 hrs to fix
data_capture/schedules/s736.py on lines 112..122

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

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

def get_contracts_queryset(request_params, wage_field):
    """
    Filters and returns contracts based on query params

    Args:
Severity: Minor
Found in api/views.py - About 5 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

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

export function ContractNum({ setSchedule, setQueryBy, queryBy }) {
  const handleClick = (e) => {
    // unset selectedSchedule if it has been previously set
    setSchedule('');
    setQueryBy(e.target.value);
frontend/source/js/data-explorer/components/vendor-search.jsx on lines 11..31

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

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

export function Vendor({ setSchedule, setQueryBy, queryBy }) {
  const handleClick = (e) => {
    // unset selectedSchedule if it has been previously set
    setSchedule('');
    setQueryBy(e.target.value);
frontend/source/js/data-explorer/components/contract-search.jsx on lines 11..31

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

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

File settings.py has 367 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
Django settings for calc project.

For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/
Severity: Minor
Found in calc/settings.py - About 4 hrs to fix

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

    COLUMN_TITLES = {
        'sin': ColumnTitle(
            canonical_name=r'SIN(s) PROPOSED',
            alternatives=[
                re.compile(r'SIN.*')
    Severity: Major
    Found in data_capture/schedules/s70.py and 1 other location - About 4 hrs to fix
    data_capture/schedules/s736.py on lines 71..93

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

    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

    COLUMN_TITLES = {
        'sin': ColumnTitle(
            canonical_name=r'SIN(s) PROPOSED',
            alternatives=[
                re.compile(r'SIN.*')
    Severity: Major
    Found in data_capture/schedules/s736.py and 1 other location - About 4 hrs to fix
    data_capture/schedules/s70.py on lines 21..43

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

    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 render has 107 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      render() {
        const prefixId = name => `${this.props.idPrefix}${name}`;
    
        return (
          <form
    Severity: Major
    Found in frontend/source/js/data-explorer/components/app.jsx - About 4 hrs to fix

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

        t.selectAll('.bar')
          .each((d) => {
            d.x = x(d.min);
            d.width = x(d.max) - d.x;
            d.height = heightScale(d.count);
      Severity: Major
      Found in frontend/source/js/data-explorer/components/histogram.jsx and 1 other location - About 4 hrs to fix
      frontend/source/js/data-explorer/components/histogram.jsx on lines 368..376

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

      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

        t.selectAll('.bar')
          .each((d) => {
            d.x = x(d.min);
            d.width = x(d.max) - d.x;
            d.height = heightScale(d.count);
      Severity: Major
      Found in frontend/source/js/data-explorer/components/histogram.jsx and 1 other location - About 4 hrs to fix
      frontend/source/js/data-explorer/components/histogram.jsx on lines 381..389

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

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

      def handle_cancel(*args, redirect_name='index', key_prefix='data_capture:'):
          '''
          Decorator to handle cancel behavior in Data Capture flows.
          The associated request's POST data is checked for a 'cancel' key,
          and, if found, all session keys that start with `key_prefix`
      Severity: Minor
      Found in data_capture/decorators.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

      Function attachedCallback has 85 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        attachedCallback() {
          const $el = $(this);
          const $input = $('input', $el);
      
          if ($input.length !== 1 || $input.attr('is') !== 'upload-input') {
      Severity: Major
      Found in frontend/source/js/data-capture/upload.js - About 3 hrs to fix

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

            @classmethod
            def load_from_upload(cls, f):
                try:
                    rows = glean_labor_categories_from_file(f)
                    return Schedule736PriceList(rows)
        Severity: Major
        Found in data_capture/schedules/s736.py and 1 other location - About 3 hrs to fix
        data_capture/schedules/s70.py on lines 273..283

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

        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

            @classmethod
            def load_from_upload(cls, f):
                try:
                    rows = glean_labor_categories_from_file(f)
                    return Schedule70PriceList(rows)
        Severity: Major
        Found in data_capture/schedules/s70.py and 1 other location - About 3 hrs to fix
        data_capture/schedules/s736.py on lines 294..304

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

        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 render has 79 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          render() {
            const { levels, idPrefix } = this.props;
            const inputs = Object.keys(EDU_LABELS).map((value) => {
              const id = idPrefix + value;
              return (
        Severity: Major
        Found in frontend/source/js/data-explorer/components/education-level.jsx - About 3 hrs to fix

          File price_list_upload.py has 295 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import json
          
          from django.views.decorators.http import require_http_methods
          from django.shortcuts import redirect, render
          from django.template.loader import render_to_string
          Severity: Minor
          Found in data_capture/views/price_list_upload.py - About 3 hrs to fix

            Function updateHistogram has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

            function updateHistogram(rootEl, data, proposedPrice, showTransition) {
              const width = 720;
              const height = 300;
              const pad = [120, 15, 60, 60];
              const top = pad[0];
            Severity: Minor
            Found in frontend/source/js/data-explorer/components/histogram.jsx - 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

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

            import hashlib
            import logging
            
            from django.db import models
            from django.contrib.auth.models import User
            Severity: Minor
            Found in data_capture/models.py - About 2 hrs to fix
              Severity
              Category
              Status
              Source
              Language