Showing 95 of 177 total issues

Function matches has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def matches(self, value):
        normval = self.normalize(value)
        if self.normalize(self.canonical_name) == normval:
            return True
        for alt in self.alternatives:
Severity: Minor
Found in data_capture/schedules/spreadsheet_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 render has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    return (
      <div className="html-dropdown">
        <button
          type="button"
Severity: Minor
Found in frontend/source/js/data-explorer/components/search-category.jsx - About 1 hr to fix

    Function createButtonText has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      createButtonText() {
        const { selectedSchedule, queryBy } = this.props;
        let searchSummary;
        if (queryBy === QUERY_BY_SCHEDULE) {
          const allSchedsLabel = `${Object.keys(scheduleLabels).length} contract vehicles`;
    Severity: Minor
    Found in frontend/source/js/data-explorer/components/search-category.jsx - About 1 hr to fix

      Function render has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        render() {
          const id = `${this.props.idPrefix}results-table`;
          const idHref = `#${id}`;
      
          return (
      Severity: Minor
      Found in frontend/source/js/data-explorer/components/results-table/index.jsx - About 1 hr to fix

        Function makeInput has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          const makeInput = (value, label) => {
            const id = value.replace(/ /g, '-').toLowerCase() || 'all-schedules';
            const makeLabel = (title) => {
              let scheduleLabel = title;
              let labelSuffix;
        Severity: Minor
        Found in frontend/source/js/data-explorer/components/schedule.jsx - About 1 hr to fix

          Function describe has 9 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def describe(cursor, vocab, labor_category, min_years_experience,
          Severity: Major
          Found in data_capture/analysis/core.py - About 1 hr to fix

            Function render has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              render() {
                // Note that Chrome has issues with number input, so we're just
                // going to use a standard text field here. This is unfortunate for
                // mobile users, since they won't get a numeric keypad.
                //
            Severity: Minor
            Found in frontend/source/js/data-explorer/components/proposed-price.jsx - About 1 hr to fix

              Function step_1 has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              def step_1(request, step):
                  if request.method == 'GET':
                      form = forms.Step1Form(data=get_nested_item(
                          request.session,
                          (SESSION_KEY, 'step_1_POST')
              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 describe has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              def describe(cursor, vocab, labor_category, min_years_experience,
                           education_level, price, severe_stddevs=2,
                           min_comparables=DEFAULT_MIN_COMPARABLES,
                           cache=None):
                  if cache is 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 appendHighlightedTerm has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function appendHighlightedTerm($el, term, searchStr) {
                const sanitizedSearch = searchStr.replace(/[^a-z0-9 ]/gi, '')
                  .trim()
                  .split(/[ ]+/)
                  .join('|');
              Severity: Minor
              Found in frontend/source/js/data-explorer/autocomplete.js - About 1 hr to fix

                Function listItem has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  const listItem = (year) => {
                    const { className, shortLabel, idSuffix } = YEAR_LI_INFO[year];
                    const id = `${idPrefix}${idSuffix}`;
                
                    return (
                Severity: Minor
                Found in frontend/source/js/data-explorer/components/contract-year.jsx - About 1 hr to fix

                  Function render has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    render() {
                      const id = `${this.props.idPrefix}labor_category`;
                      let placeholder = "Type a labor category";
                  
                      if (this.props.queryBy === QUERY_BY_CONTRACT) {
                  Severity: Minor
                  Found in frontend/source/js/data-explorer/components/labor-category.jsx - About 1 hr to fix

                    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

                    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

                    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

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

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

                          Severity
                          Category
                          Status
                          Source
                          Language