Showing 95 of 177 total issues

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

    Avoid too many return statements within this function.
    Open

        return step.render(request, {
    Severity: Major
    Found in data_capture/views/price_list_replace.py - About 30 mins to fix

      Function absolutify_url has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def absolutify_url(url: str) -> str:
          '''
          If the URL is an absolute path, returns the URL prefixed with
          the current Site's protocol and host information.
      
      
      Severity: Minor
      Found in calc/site_utils.py - About 25 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 toggleErrorMsg has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export function toggleErrorMsg(window, options) {
        if (options.parent) {
          // I'm tired of typing `options`
          const { parent } = options;
          const errorContainer = parent.querySelector(`.${INVALID_MESSAGE_CLASS}`)
      Severity: Minor
      Found in frontend/source/js/data-capture/form-validation.js - About 25 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 write_roman has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def write_roman(num):
          roman: OrderedDict[int, str] = OrderedDict()
          roman[1000] = "M"
          roman[900] = "CM"
          roman[500] = "D"
      Severity: Minor
      Found in data_capture/analysis/vocabulary.py - About 25 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 recordable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def recordable(self, func):
              '''
              A view decorator that makes a view recordable and replayable.
      
              The view will be passed 'recorder' as a keyword argument;
      Severity: Minor
      Found in data_capture/views/replay.py - About 25 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 componentDidUpdate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        componentDidUpdate(_, prevState) {
          if (prevState.typed !== this.state.typed) {
            const value = this.state.typed;
            const floatValue = value ? parseFloat(value) : 0;
            if (!isNaN(floatValue) && floatValue >= 0) { /* eslint-disable-line no-restricted-globals */
      Severity: Minor
      Found in frontend/source/js/data-explorer/components/proposed-price.jsx - About 25 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 wait_for_db has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def wait_for_db(max_attempts=15, seconds_between_attempts=1):
          # type: (int, int) -> None
          '''
          Some manage.py commands interact with the database, and we want
          them to be directly callable from `docker-compose run`. However,
      Severity: Minor
      Found in docker_django_management.py - About 25 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 order_by has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def order_by(self, *args, **kwargs):
              edu_sort_sql = """
                  case
                      when education_level = 'HS' then 1
                      when education_level = 'AA' then 2
      Severity: Minor
      Found in contracts/models.py - About 25 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 convert_next has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def convert_next(self):
              '''
              Returns a generator that yields converted rows. The conversion is
              from the related xls_file to the CSV row format expected by
              contracts.loaders.region_10.Region10Loader
      Severity: Minor
      Found in data_capture/r10_spreadsheet_converter.py - About 25 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 bulk_update_normalized_labor_categories has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def bulk_update_normalized_labor_categories(self):
              '''
              Iterate through all Contract models and update their
              normalized labor categories if necessary.
      
      
      Severity: Minor
      Found in contracts/models.py - About 25 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 has_existing_contract_number_error has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def has_existing_contract_number_error(self):
              if 'contract_number' in self.errors:
                  for err in self.errors.as_data()['contract_number']:
                      if isinstance(err, DuplicateContractValidationError):
                          return True
      Severity: Minor
      Found in data_capture/forms/price_list.py - About 25 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 from_list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def from_list(cls, docs):
              vocab = cls()
              for doc in docs:
                  words = doc.split()
                  for word in words:
      Severity: Minor
      Found in data_capture/analysis/vocabulary.py - About 25 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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export function initialize(el, {
        api,
        getQueryType,
        setFieldValue,
      }) {
      Severity: Minor
      Found in frontend/source/js/data-explorer/autocomplete.js - About 25 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 generate_username has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def generate_username(self, email, max_attempts=100):
              '''
              Generate a unique username based on the given email address
              by slugifying the first several characters of the username
              part of the email. If needed, a number is added at the end
      Severity: Minor
      Found in data_capture/admin.py - About 25 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

      Severity
      Category
      Status
      Source
      Language