fairplaysk/datacamp

View on GitHub
lib/etl/vvo_v2/performance_information_parser.rb

Summary

Maintainability
F
3 days
Test Coverage

Method performance_information has a Cognitive Complexity of 119 (exceeds 5 allowed). Consider refactoring.
Open

      def performance_information
        performance_information_hash = {}

        case document_format
          when :format1
Severity: Minor
Found in lib/etl/vvo_v2/performance_information_parser.rb - About 2 days 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

Method performance_information has 141 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def performance_information
        performance_information_hash = {}

        case document_format
          when :format1
Severity: Major
Found in lib/etl/vvo_v2/performance_information_parser.rb - About 5 hrs to fix

    Avoid deeply nested control flow statements.
    Open

                            if price_value_element
                              price_hash = parse_price2(price_value_element)
                              performance_information_hash[:procurement_currency] = price_hash[:currency]
                              performance_information_hash[:draft_price] = price_hash[:price]
                              performance_information_hash[:draft_price_vat_included] = price_hash[:price_vat_included]
    Severity: Major
    Found in lib/etl/vvo_v2/performance_information_parser.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if price_value_element
                                price_hash = parse_price1(price_value_element)
                                performance_information_hash[:procurement_currency] = price_hash[:currency]
                                performance_information_hash[:draft_price] = price_hash[:price]
                                performance_information_hash[:draft_price_vat_included] = price_hash[:price_vat_included]
      Severity: Major
      Found in lib/etl/vvo_v2/performance_information_parser.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            while duration_element && duration_element.xpath(".//span[@class='code']").inner_text.blank?
                              if duration_element.inner_text.match(/Trvanie/)
                                performance_information_hash[:duration_unit] = duration_element.xpath(".//span[1]").inner_text.strip
                              elsif duration_element.inner_text.match(/Hodnota/)
                                performance_information_hash[:duration] = duration_element.xpath(".//span[1]").inner_text.to_i
        Severity: Major
        Found in lib/etl/vvo_v2/performance_information_parser.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                elsif price_element.inner_text.strip.match(/Skutočne zaplatená cena/)
                                  price_value_element = next_price_value_element(price_element)
                                  if price_value_element
                                    price_hash = parse_price1(price_value_element)
                                    performance_information_hash[:procurement_currency] = price_hash[:currency]
          Severity: Major
          Found in lib/etl/vvo_v2/performance_information_parser.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                  elsif price_element.inner_text.strip.match(/Skutočne zaplatená cena/)
                                    price_value_element = next_price_value_element(price_element)
                                    if price_value_element
                                      price_hash = parse_price2(price_value_element)
                                      performance_information_hash[:procurement_currency] = price_hash[:currency]
            Severity: Major
            Found in lib/etl/vvo_v2/performance_information_parser.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  while duration_element && duration_element.xpath(".//td[@class='kod']").inner_text.blank?
                                    if duration_element.xpath(".//span[@class='podnazov']").inner_text.match(/Trvanie/)
                                      duration_unit = strip_last_point(duration_element.xpath(".//span[@class='hodnota']").inner_text.strip)
                                      performance_information_hash[:duration_unit] = duration_unit if duration_unit != "v intervale"
                                    elsif duration_element.xpath(".//span[@class='podnazov']").inner_text.match(/Hodnota/)
              Severity: Major
              Found in lib/etl/vvo_v2/performance_information_parser.rb - About 45 mins to fix

                Similar blocks of code found in 4 locations. Consider refactoring.
                Open

                                        price_value_element = next_price_value_element(price_element)
                                        if price_value_element
                                          price_hash = parse_price1(price_value_element)
                                          performance_information_hash[:procurement_currency] = price_hash[:currency]
                                          performance_information_hash[:draft_price] = price_hash[:price]
                Severity: Major
                Found in lib/etl/vvo_v2/performance_information_parser.rb and 3 other locations - About 35 mins to fix
                lib/etl/vvo_v2/performance_information_parser.rb on lines 58..64
                lib/etl/vvo_v2/performance_information_parser.rb on lines 123..129
                lib/etl/vvo_v2/performance_information_parser.rb on lines 132..138

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 34.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 4 locations. Consider refactoring.
                Open

                                        price_value_element = next_price_value_element(price_element)
                                        if price_value_element
                                          price_hash = parse_price2(price_value_element)
                                          performance_information_hash[:procurement_currency] = price_hash[:currency]
                                          performance_information_hash[:final_price] = price_hash[:price]
                Severity: Major
                Found in lib/etl/vvo_v2/performance_information_parser.rb and 3 other locations - About 35 mins to fix
                lib/etl/vvo_v2/performance_information_parser.rb on lines 49..55
                lib/etl/vvo_v2/performance_information_parser.rb on lines 58..64
                lib/etl/vvo_v2/performance_information_parser.rb on lines 123..129

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 34.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 4 locations. Consider refactoring.
                Open

                                        price_value_element = next_price_value_element(price_element)
                                        if price_value_element
                                          price_hash = parse_price2(price_value_element)
                                          performance_information_hash[:procurement_currency] = price_hash[:currency]
                                          performance_information_hash[:draft_price] = price_hash[:price]
                Severity: Major
                Found in lib/etl/vvo_v2/performance_information_parser.rb and 3 other locations - About 35 mins to fix
                lib/etl/vvo_v2/performance_information_parser.rb on lines 49..55
                lib/etl/vvo_v2/performance_information_parser.rb on lines 58..64
                lib/etl/vvo_v2/performance_information_parser.rb on lines 132..138

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 34.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 4 locations. Consider refactoring.
                Open

                                        price_value_element = next_price_value_element(price_element)
                                        if price_value_element
                                          price_hash = parse_price1(price_value_element)
                                          performance_information_hash[:procurement_currency] = price_hash[:currency]
                                          performance_information_hash[:final_price] = price_hash[:price]
                Severity: Major
                Found in lib/etl/vvo_v2/performance_information_parser.rb and 3 other locations - About 35 mins to fix
                lib/etl/vvo_v2/performance_information_parser.rb on lines 49..55
                lib/etl/vvo_v2/performance_information_parser.rb on lines 123..129
                lib/etl/vvo_v2/performance_information_parser.rb on lines 132..138

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 34.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                                      elsif duration_element.inner_text.match(/Začiatok/)
                                        performance_information_hash[:start_on] = parse_date(duration_element.xpath(".//span[1]").inner_text.strip)
                                      elsif duration_element.inner_text.match(/Ukončenie/)
                                        performance_information_hash[:end_on] = parse_date(duration_element.xpath(".//span[1]").inner_text.strip)
                                      end
                Severity: Minor
                Found in lib/etl/vvo_v2/performance_information_parser.rb and 1 other location - About 20 mins to fix
                lib/etl/vvo_v2/basic_information_parser.rb on lines 71..75

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 28.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                There are no issues that match your filters.

                Category
                Status