Showing 95 of 177 total issues

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

    def broaden_query(cursor, vocab, query, cache, min_count):
    Severity: Minor
    Found in data_capture/analysis/vocabulary.py - About 35 mins to fix

      Function send_mail has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def send_mail(subject, to, template, ctx, reply_to=None):
      Severity: Minor
      Found in data_capture/email.py - About 35 mins to fix

        Function get_best_permutations has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def get_best_permutations(vocab, lexemes, min_count=1, min_length=4,
        Severity: Minor
        Found in data_capture/analysis/vocabulary.py - About 35 mins to fix

          Function getCustomMessage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          export function getCustomMessage(type, validity) {
            if (validity.typeMismatch) {
              return ERROR_MESSAGES[`${type}Mismatch`];
            } else {
              for (const invalidKey in ERROR_MESSAGES) { // eslint-disable-line no-restricted-syntax
          Severity: Minor
          Found in frontend/source/js/data-capture/form-validation.js - About 35 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 get_template_path has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def get_template_path(template_name: str) -> Path:
              '''
              Given a Django template path, return an absolute path to it.
              '''
          
          
          Severity: Minor
          Found in styleguide/templatetags/styleguide.py - About 35 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 7 (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/region_3.py - About 35 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 step_2 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def step_2(request, step):
              # Redirect back to step 1 if we don't have data
              if get_step_form_from_session(1, request) is None:
                  return redirect('data_capture:step_1')
              else:
          Severity: Minor
          Found in data_capture/views/price_list_upload.py - About 35 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 _create_contract_batches has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def _create_contract_batches(upload_source, batch_size=5000, rows=None):
              if rows is None:
                  r10_file = ContentFile(upload_source.original_file)
                  converter = Region10SpreadsheetConverter(r10_file)
                  rows = converter.convert_next()
          Severity: Minor
          Found in data_capture/jobs.py - About 35 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 update_price_fields has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def update_price_fields(self):
                  '''
                  Set current, next, and second year price fields based on this
                  contract's contract_year.
                  '''
          Severity: Minor
          Found in contracts/models.py - About 35 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 attachedCallback has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            attachedCallback() {
              if ('isUpgraded' in this) {
                // We've already been attached.
                return;
              }
          Severity: Minor
          Found in frontend/source/js/data-capture/expandable-area.js - About 35 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 extract_min_education has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def extract_min_education(text):
              '''
              Attempts to find a valid Education Choice within the given text argument
              If a matching Education Choice is found, it is returned
          
          
          Severity: Minor
          Found in data_capture/schedules/coercers.py - About 35 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 trackInterestingLink has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          function trackInterestingLink(el) {
            if (!(el instanceof HTMLAnchorElement)) {
              return;
            }
          
          
          Severity: Minor
          Found in frontend/source/js/common/ga.js - About 35 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 load_cups_from_vcap_services has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def load_cups_from_vcap_services(name: str='calc-env',
                                           env: Environ=os.environ) -> None:
              '''
              Detects if VCAP_SERVICES exists in the environment; if so, parses
              it and imports all the credentials from the given custom
          Severity: Minor
          Found in calc/settings_utils.py - About 35 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 7 (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/region_10.py - About 35 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 7 (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/mas_consolidated.py - About 35 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 handleChange has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            handleChange(e) {
              const { value } = e.target;
              const filteredChars = [];
              let decimalFound = false;
              let centDigits = 0;
          Severity: Minor
          Found in frontend/source/js/data-explorer/components/proposed-price.jsx - About 35 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 command has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def command(user_file, groupname, dryrun):
              '''
              Bulk creates users from email addresses in the the specified text file,
              which should contain one email address per line.
              If the optional "--group <GROUPNAME>" argument is specified, then all the
          Severity: Minor
          Found in meta/management/commands/bulkcreateusers.py - About 35 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 7 (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/s03fac.py - About 35 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 too many return statements within this function.
          Open

                          return redirect('data_capture:step_5')
          Severity: Major
          Found in data_capture/views/price_list_upload.py - About 30 mins to fix
            Severity
            Category
            Status
            Source
            Language