Showing 176 of 177 total issues

Function price_list_details has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def price_list_details(request, id):
    '''
    This view shows all the details of a SubmittedPriceList model.
    Note that any logged-in user with the PRICE_LIST_UPLOAD_PERMISSION (so
    Contract Officers and above) can view the page for ANY SubmittedPriceList,
Severity: Minor
Found in data_capture/views/price_lists.py - About 55 mins 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

@require_POST
def disable(request):
    request.session[SESSION_KEY] = False
    return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))
Severity: Minor
Found in frontend/safe_mode.py and 1 other location - About 55 mins to fix
frontend/safe_mode.py on lines 13..16

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

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

def head_meta(context, *args, **kwargs):
    """
    Outputs an array of tags in the head for search engines and social media outlets
    including relevant icon and image meta tags.

Severity: Minor
Found in data_explorer/templatetags/data_explorer_tags.py - About 55 mins 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

@require_POST
def enable(request):
    request.session[SESSION_KEY] = True
    return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))
Severity: Minor
Found in frontend/safe_mode.py and 1 other location - About 55 mins to fix
frontend/safe_mode.py on lines 19..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 37.

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 find_comparable_contracts has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

def find_comparable_contracts(cursor, vocab, labor_category,
Severity: Major
Found in data_capture/analysis/core.py - About 50 mins to fix

    Function log_m2m_change has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def log_m2m_change(sender, instance, action, reverse, model, pk_set, **kwargs):
    Severity: Major
    Found in data_capture/signals.py - About 50 mins to fix

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

      function minExperience(state = MIN_EXPERIENCE, action) {
        if (action.type === SET_EXPERIENCE && action.subtype === 'min') {
          return action.years;
        }
        return state;
      Severity: Minor
      Found in frontend/source/js/data-explorer/reducers.js and 1 other location - About 50 mins to fix
      frontend/source/js/data-explorer/reducers.js on lines 80..85

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

      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

      function maxExperience(state = MAX_EXPERIENCE, action) {
        if (action.type === SET_EXPERIENCE && action.subtype === 'max') {
          return action.years;
        }
        return state;
      Severity: Minor
      Found in frontend/source/js/data-explorer/reducers.js and 1 other location - About 50 mins to fix
      frontend/source/js/data-explorer/reducers.js on lines 73..78

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

      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

      Vendor.propTypes = {
        setQueryBy: PropTypes.func.isRequired,
        setSchedule: PropTypes.func.isRequired,
        queryBy: PropTypes.string.isRequired,
      };
      Severity: Minor
      Found in frontend/source/js/data-explorer/components/vendor-search.jsx and 1 other location - About 50 mins to fix
      frontend/source/js/data-explorer/components/contract-search.jsx on lines 33..37

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

      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

      ContractNum.propTypes = {
        setQueryBy: PropTypes.func.isRequired,
        setSchedule: PropTypes.func.isRequired,
        queryBy: PropTypes.string.isRequired,
      };
      Severity: Minor
      Found in frontend/source/js/data-explorer/components/contract-search.jsx and 1 other location - About 50 mins to fix
      frontend/source/js/data-explorer/components/vendor-search.jsx on lines 33..37

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

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

      def generate_column_index_map(heading_row, field_title_map):
          def find_col(col_title):
              for idx, cell in enumerate(heading_row):
                  if col_title.matches(cell.value):
                      return idx
      Severity: Minor
      Found in data_capture/schedules/spreadsheet_utils.py - About 45 mins 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 glean_labor_categories_from_book has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def glean_labor_categories_from_book(book, sheet_name=DEFAULT_SHEET_NAME):
          if sheet_name not in book.sheet_names():
              raise ValidationError(
                  'There is no sheet in the workbook called "%s".' % sheet_name
              )
      Severity: Minor
      Found in data_capture/schedules/s70.py - About 45 mins 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 replace_step_1 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def replace_step_1(request, id, step):
          price_list = price_list = get_object_or_404(SubmittedPriceList, pk=id)
          schedule_class = registry.get_class(price_list.schedule)
      
          if request.method == 'GET':
      Severity: Minor
      Found in data_capture/views/price_list_replace.py - About 45 mins 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

      Avoid deeply nested control flow statements.
      Open

              if (el.checked) {
                formData.append(el.name, el.value);
              }
      Severity: Major
      Found in frontend/source/js/data-capture/ajaxform.js - About 45 mins to fix

        Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(self, attrs=None, degraded=False, required=True,
        Severity: Minor
        Found in frontend/upload.py - About 45 mins to fix

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

          def glean_labor_categories_from_file(f, sheet_name=DEFAULT_SHEET_NAME):
              book = xlrd.open_workbook(file_contents=f.read())
              return glean_labor_categories_from_book(book, sheet_name)
          Severity: Major
          Found in data_capture/schedules/region_10.py and 5 other locations - About 40 mins to fix
          data_capture/schedules/mas_consolidated.py on lines 82..84
          data_capture/schedules/region_3.py on lines 61..63
          data_capture/schedules/s03fac.py on lines 71..73
          data_capture/schedules/s70.py on lines 101..114
          data_capture/schedules/s736.py on lines 126..128

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

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

          def glean_labor_categories_from_file(f, sheet_name=DEFAULT_SHEET_NAME):
              book = xlrd.open_workbook(file_contents=f.read())
              return glean_labor_categories_from_book(book, sheet_name)
          Severity: Major
          Found in data_capture/schedules/s03fac.py and 5 other locations - About 40 mins to fix
          data_capture/schedules/mas_consolidated.py on lines 82..84
          data_capture/schedules/region_10.py on lines 71..73
          data_capture/schedules/region_3.py on lines 61..63
          data_capture/schedules/s70.py on lines 101..114
          data_capture/schedules/s736.py on lines 126..128

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

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

          def glean_labor_categories_from_file(f, sheet_name=DEFAULT_SHEET_NAME):
              book = xlrd.open_workbook(file_contents=f.read())
              return glean_labor_categories_from_book(book, sheet_name)
          Severity: Major
          Found in data_capture/schedules/s736.py and 5 other locations - About 40 mins to fix
          data_capture/schedules/mas_consolidated.py on lines 82..84
          data_capture/schedules/region_10.py on lines 71..73
          data_capture/schedules/region_3.py on lines 61..63
          data_capture/schedules/s03fac.py on lines 71..73
          data_capture/schedules/s70.py on lines 101..114

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

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

          def glean_labor_categories_from_file(f, sheet_name=DEFAULT_SHEET_NAME):
              book = xlrd.open_workbook(file_contents=f.read())
              return glean_labor_categories_from_book(book, sheet_name)
          Severity: Major
          Found in data_capture/schedules/mas_consolidated.py and 5 other locations - About 40 mins to fix
          data_capture/schedules/region_10.py on lines 71..73
          data_capture/schedules/region_3.py on lines 61..63
          data_capture/schedules/s03fac.py on lines 71..73
          data_capture/schedules/s70.py on lines 101..114
          data_capture/schedules/s736.py on lines 126..128

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

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

          def glean_labor_categories_from_file(f, sheet_name=DEFAULT_SHEET_NAME):
              book = xlrd.open_workbook(file_contents=f.read())
              return glean_labor_categories_from_book(book, sheet_name)
          Severity: Major
          Found in data_capture/schedules/region_3.py and 5 other locations - About 40 mins to fix
          data_capture/schedules/mas_consolidated.py on lines 82..84
          data_capture/schedules/region_10.py on lines 71..73
          data_capture/schedules/s03fac.py on lines 71..73
          data_capture/schedules/s70.py on lines 101..114
          data_capture/schedules/s736.py on lines 126..128

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

          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

          Severity
          Category
          Status
          Source
          Language