Showing 95 of 177 total issues

File email.py has 261 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import re
from functools import wraps
from django.core.mail import EmailMultiAlternatives, get_connection
from django.utils.html import strip_tags
from django.utils import timezone
Severity: Minor
Found in data_capture/email.py - About 2 hrs to fix

    Function generate_column_index_map_mas has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def generate_column_index_map_mas(heading_row, field_title_map):
        def find_col_mas(col_title):
            for idx, cell in enumerate(heading_row):
                Is_Include = True
                if str(col_title).lower() == 'price offered' and idx == 18:
    Severity: Minor
    Found in data_capture/schedules/spreadsheet_utils.py - 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

    Function smart_load_from_upload has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def smart_load_from_upload(classname: str, f: UploadedFile) -> BasePriceList:
        '''
        Attempt to intelligently load the given Django UploadedFile,
        interpreting it as a price list for the given schedule class name.
    
    
    Severity: Minor
    Found in data_capture/schedules/registry.py - 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

    Function execute_from_command_line has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def execute_from_command_line(argv):  # type: (List[str]) -> None
        '''
        This is like django.core.management.execute_from_command_line,
        but if the django package is unavailable, the script executes itself
        inside a docker container, where the django package is assumed
    Severity: Minor
    Found in docker_django_management.py - 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

    Function populateFormData has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

      populateFormData(formData) {
        // IE11 doesn't support FormData.prototype.delete(), so we need to
        // manually construct the FormData ourselves (we used to have
        // the browser construct it for us, and then replace the file).
        for (let i = 0; i < this.elements.length; i++) {
    Severity: Minor
    Found in frontend/source/js/data-capture/ajaxform.js - 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 docker_django_management.py has 253 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #!/usr/bin/env python
    
    '''
        Docker Django Management v0.1
    
    
    Severity: Minor
    Found in docker_django_management.py - About 2 hrs to fix

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

      def step_4(request, step):
          gleaned_data = get_deserialized_gleaned_data(request)
      
          if gleaned_data is None:
              return redirect('data_capture:step_3')
      Severity: Minor
      Found in data_capture/views/price_list_upload.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 step_3 has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      def step_3(request, step, recorder):
          if get_step_form_from_session(2, request) is None:
              return redirect('data_capture:step_2')
      
          session_pl = request.session[SESSION_KEY]
      Severity: Minor
      Found in data_capture/views/price_list_upload.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 checkInputs has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function checkInputs(window, inputs) {
        inputs.singleInputs.forEach((input) => {
          // prevent showing the HTML5 tooltip
          input.addEventListener('invalid', (e) => {
            e.preventDefault();
      Severity: Minor
      Found in frontend/source/js/data-capture/form-validation.js - About 1 hr to fix

        Function get_histogram has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_histogram(values: List[SupportsFloat], num_bins: int=10) -> List[dict]:
            """
            Get a histogram of a list of numeric values.
            Returns array of "bin" dicts with keys `count`, `max`, and `min`.
            """
        Severity: Minor
        Found in api/utils.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 iter_api_pages has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        def iter_api_pages(url, start_page=1, end_page=None):
            page = start_page
            while True:
                if end_page is not None and page > end_page:
                    break
        Severity: Minor
        Found in api/management/commands/load_api_data.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 get_best_permutations has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_best_permutations(vocab, lexemes, min_count=1, min_length=4,
                                  max_permutations=8):
            def compare(a, b):
                a_len = len(a)
                b_len = len(b)
        Severity: Minor
        Found in data_capture/analysis/vocabulary.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 attachedCallback has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          attachedCallback() {
            const $el = $(this);
            const $input = $('input', $el);
        
            if ($input.length !== 1 || $input.attr('is') !== 'upload-input') {
        Severity: Minor
        Found in frontend/source/js/data-capture/upload.js - 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 process_pages has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def process_pages(self, pages, dry_run):
                num_rates = 0
                num_pages = 0
                progress_bar = None
        
        
        Severity: Minor
        Found in api/management/commands/load_api_data.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 analyze_step_2 has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        def analyze_step_2(request, step):
            step_1_post_data = get_nested_item(request.session, (
                'data_capture:analyze_price_list',
                'step_1_POST'
            ))
        Severity: Minor
        Found in data_capture/views/price_list_analyze.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 view has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        def view(request):
            form = None
        
            if request.method == 'POST':
                if 'cancel' in request.POST:
        Severity: Minor
        Found in styleguide/ajaxform_example.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 find_comparable_contracts has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def find_comparable_contracts(cursor, vocab, labor_category,
                                      min_years_experience, education_level,
                                      min_count=DEFAULT_MIN_COMPARABLES,
                                      cache=None):
            '''
        Severity: Minor
        Found in data_capture/analysis/core.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 get_heading_indices_map has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_heading_indices_map(self, raises=True):
                '''
                Given a sheet, returns a mapping of R10 Excel sheet headings
                to the column indices associated with those fields in that sheet
                '''
        Severity: Minor
        Found in data_capture/r10_spreadsheet_converter.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 Description has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        export function Description({
          shownResults,
          totalResults,
          minExperience,
          maxExperience,
        Severity: Minor
        Found in frontend/source/js/data-explorer/components/description.jsx - 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 glean_labor_categories_from_book has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def glean_labor_categories_from_book(book, sheet_name=DEFAULT_SHEET_NAME):
            # TODO: This should be DRY'd out a bit since it is extremely similar
            # to the s70.py function of the same name.
        
            if sheet_name not in book.sheet_names():
        Severity: Minor
        Found in data_capture/schedules/s736.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