fairplaysk/datacamp

View on GitHub

Showing 350 of 350 total issues

Avoid deeply nested control flow statements.
Open

                    if nuts_header.match(/NUTS/)
                      tr_nuts_content_element = next_element(tr_nuts_element)
                      nuts_code = tr_nuts_content_element.xpath(".//span[@class='hodnota']").inner_text.strip
                      contract_information_hash[:nuts_code] = strip_last_point(nuts_code)
                    end
Severity: Major
Found in lib/etl/vvo_v2/contract_information_parser.rb - About 45 mins to fix

    Method load_record has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def load_record
        @dataset_description = DatasetDescription.find(params[:dataset_id])
        @dataset_class       = @dataset_description.dataset_model
    
        if params[:id]
    Severity: Minor
    Found in app/controllers/records_controller.rb - 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 first_criteria_element.any?
                          procedure_offers_criteria = strip_last_point(first_criteria_element.inner_text.strip)
                          next_criteria_element = tr_first_criteria_element.next_sibling
                          while next_criteria_element && next_criteria_element.xpath(".//td[@class='kod']").inner_text.blank?
                            if next_criteria_element.inner_text.strip.present?
    Severity: Major
    Found in lib/etl/vvo_v2/procedure_information_parser.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                      if project_type_element
                        header_procedure_and_project_information_hash[:project_type] = project_type_element.inner_text
                      end
      Severity: Major
      Found in lib/etl/vvo_v2/basic_information_parser.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if place_header.match(/V prípade zmluvy/)
                              tr_place_element = next_element(tr_place_element)
                              place_header = tr_place_element.xpath(".//span[@class='podnazov']").inner_text
                            end
        Severity: Major
        Found in lib/etl/vvo_v2/contract_information_parser.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                      if @filters['quality_status'] == 'absent'
                        @dataset_class = @dataset_class.where('t.quality_status IS NULL OR t.quality_status = ?', @filters['quality_status'])
                      else
                        @dataset_class = @dataset_class.where('t.quality_status = ?', @filters['quality_status'])
                      end
          Severity: Major
          Found in app/controllers/datasets_controller.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                              if price_detail.inner_text.match(/Hodnota udelených (cien|ocenení) a\/alebo odmien(.*)DPH/)
                                supplier[:vat_included] = !price_detail.inner_text.match(/Hodnota udelených (cien|ocenení) a\/alebo odmien(.*)(.)DPH/)[2].downcase.match(/bez/)
            
                                prices = price_detail.xpath(".//span")
                                supplier[:price] = prices[0].inner_text.gsub(' ', '').gsub(',', '.').to_f
            Severity: Major
            Found in lib/etl/vvo_extraction.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if dictionary_element.xpath(".//div[2]").inner_text.match(/Doplňujúce predmety/) && dictionary_element.xpath(".//div[3]").any?
                                    dictionary_additional_subjects = dictionary_element.xpath(".//div[3]").inner_text.match(/Hlavný slovník: (.*)/)
                                    if dictionary_additional_subjects && dictionary_additional_subjects.size > 1
                                      contract_information_hash[:dictionary_additional_subjects] = dictionary_additional_subjects[1].strip
                                    end
              Severity: Major
              Found in lib/etl/vvo_v2/contract_information_parser.rb - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                  elsif code_text.match(/^IV.2.2/) && header_text.match(/Využila sa elektronická aukcia/)
                                    auction_element = tr.xpath(".//td[2]//span[@class='hodnota']")
                                    procedure_information_hash[:procedure_use_auction] = auction_element.inner_text.strip.match(/Áno/).present?
                
                                  elsif code_text.match(/^IV.3.2/) && header_text.match(/Predchádzajúce oznámenie/)
                Severity: Major
                Found in lib/etl/vvo_v2/procedure_information_parser.rb - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                        if type_element.next_sibling.next_sibling.inner_text.match(/Kategória služby číslo/)
                                          category_element = type_element.next_sibling.next_sibling
                                          contract_information_hash[:project_category] = category_element.xpath(".//span[2]").inner_text.strip
                                        else #237455
                                          category_element = type_element
                  Severity: Major
                  Found in lib/etl/vvo_v2/contract_information_parser.rb - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                      elsif code_text.match(/^II.1.6/) && (header_text.match(/Informácie o rámcovej dohode/) || header_text.match(/GPA/))
                                        gpa_agreement = code.parent.next_sibling.next_sibling.xpath(".//span")
                                        contract_information_hash[:gpa_agreement] = !gpa_agreement.inner_text.match(/Nie/)
                    Severity: Major
                    Found in lib/etl/vvo_v2/contract_information_parser.rb - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                        supplier[:note] = "Zahranicne IČO: #{supplier[:supplier_ico]}" if supplier[:supplier_ico] && supplier[:supplier_ico].class != Float
                      Severity: Major
                      Found in lib/etl/vvo_extraction.rb - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            while notification_element && notification_element.xpath(".//span[@class='code']").inner_text.blank?
                                              if notification_element.inner_text.match(/Číslo oznámenia v(.*)EÚ/)
                                                if notification_element.xpath(".//span")
                                                  eu_number = notification_element.xpath(".//span").inner_text.strip
                                                  date_element = notification_element.xpath(".//span").first.next_sibling
                        Severity: Major
                        Found in lib/etl/vvo_v2/additional_information_parser.rb - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if supplier_hash.any?
                                                suppliers << supplier_hash if supplier_hash[:supplier_name]
                                                supplier_hash = {}
                                              end
                          Severity: Major
                          Found in lib/etl/vvo_v2/suppliers_information_parser.rb - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                  if nuts_element.xpath(".//div").any?
                                                    contract_information_hash[:nuts_code] = nuts_element.xpath(".//div").inner_text
                                                  else
                                                    contract_information_hash[:nuts_code] = next_element(nuts_element).inner_text.strip
                                                  end
                            Severity: Major
                            Found in lib/etl/vvo_v2/contract_information_parser.rb - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  next unless tr_place_element
                              Severity: Major
                              Found in lib/etl/vvo_v2/contract_information_parser.rb - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    if supplier_hash.any?
                                                      suppliers << supplier_hash if supplier_hash[:supplier_name]
                                                      supplier_hash = {}
                                                    end
                                Severity: Major
                                Found in lib/etl/vvo_v2/suppliers_information_parser.rb - About 45 mins to fix

                                  Method basic_information has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                        def basic_information
                                          header = document.xpath("//div[@class='oznamenie']")
                                  
                                          procurement_code = bulletin_code = year = published_on = procurement_type = nil
                                  
                                  
                                  Severity: Minor
                                  Found in lib/etl/vvo_v2/basic_information_parser.rb - 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

                                                      next unless tr_nuts_element
                                  Severity: Major
                                  Found in lib/etl/vvo_v2/contract_information_parser.rb - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                          while next_criteria_element && next_criteria_element.xpath(".//span[@class='code']").empty?
                                                            if next_criteria_element.inner_text.strip.present?
                                                              procedure_offers_criteria+= ', ' + next_criteria_element.inner_text.strip
                                                            end
                                                            next_criteria_element = next_criteria_element.next_sibling
                                    Severity: Major
                                    Found in lib/etl/vvo_v2/procedure_information_parser.rb - About 45 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language