ikuseiGmbH/smart-village-app-converter-xml2json

View on GitHub
app/models/record/poi_record.rb

Summary

Maintainability
C
1 day
Test Coverage

File poi_record.rb has 340 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class PoiRecord < Record

  # Load poi data from external source
  # and save it to local attribute 'xml_data'
  #
Severity: Minor
Found in app/models/record/poi_record.rb - About 4 hrs to fix

    Class PoiRecord has 32 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class PoiRecord < Record
    
      # Load poi data from external source
      # and save it to local attribute 'xml_data'
      #
    Severity: Minor
    Found in app/models/record/poi_record.rb - About 4 hrs to fix

      Method parse_price_informations has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Wontfix

          def parse_price_informations(xml_part)
            price_data = []
            xml_part.xpath("price/pricerangecomplex").each do |price|
              amount = price.at_xpath("price").try(:text)
              age_from = price.at_xpath("agefrom").try(:text)
      Severity: Minor
      Found in app/models/record/poi_record.rb - 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

      Method parse_data has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Wontfix

        def parse_data
          @xml_doc = Nokogiri.XML(xml_data)
          @xml_doc.remove_namespaces!
          @base_file_url = @xml_doc.at_xpath("/result/@fileUrl").try(:value)
          potential_target_servers = Rails.application.credentials.target_servers
      Severity: Minor
      Found in app/models/record/poi_record.rb - 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

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

        def load_xml_data
          url = Rails.application.credentials.poi_source[:url]
          pem = Rails.application.credentials.tmb_auth[:pem]
          password = Rails.application.credentials.tmb_auth[:password]
          result = ApiRequestService.new(url).get_request(false, pem, password)
      Severity: Major
      Found in app/models/record/poi_record.rb and 1 other location - About 1 hr to fix
      app/models/record/event_record.rb on lines 7..17

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

      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

          def district_name_for_location(location)
            district_node = location.xpath("district/district").first
            district_ids = district_node.attributes["id"].try(:value) if district_node.present?
            district = @xml_doc.xpath("/result/district[@id='#{district_ids}']").first if district_ids.present?
      
      
      Severity: Major
      Found in app/models/record/poi_record.rb and 3 other locations - About 40 mins to fix
      app/models/record/poi_record.rb on lines 335..340
      app/models/record/poi_record.rb on lines 351..356
      app/models/record/poi_record.rb on lines 359..364

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

      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

          def region_name_for_location(location)
            region_node = location.xpath("region/region").first
            region_ids = region_node.attributes["id"].try(:value) if region_node.present?
            region = @xml_doc.xpath("/result/region[@id='#{region_ids}']").first if region_ids.present?
      
      
      Severity: Major
      Found in app/models/record/poi_record.rb and 3 other locations - About 40 mins to fix
      app/models/record/poi_record.rb on lines 335..340
      app/models/record/poi_record.rb on lines 343..348
      app/models/record/poi_record.rb on lines 359..364

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

      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

          def state_for_location(location)
            state_node = location.xpath("state").first
            state_id = state_node.attributes["id"].try(:value) if state_node.present?
            state = @xml_doc.xpath("/result/state[@id='#{state_id}']").first if state_id.present?
      
      
      Severity: Major
      Found in app/models/record/poi_record.rb and 3 other locations - About 40 mins to fix
      app/models/record/poi_record.rb on lines 335..340
      app/models/record/poi_record.rb on lines 343..348
      app/models/record/poi_record.rb on lines 351..356

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

      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

          def department_name_for_location(location)
            department_node = location.xpath("department/department").first
            department_ids = department_node.attributes["id"].try(:value) if department_node.present?
            department = @xml_doc.xpath("/result/department[@id='#{department_ids}']").first if department_ids.present?
      
      
      Severity: Major
      Found in app/models/record/poi_record.rb and 3 other locations - About 40 mins to fix
      app/models/record/poi_record.rb on lines 343..348
      app/models/record/poi_record.rb on lines 351..356
      app/models/record/poi_record.rb on lines 359..364

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

      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 3 locations. Consider refactoring.
      Open

              address: {
                addition: xml_part.at_xpath("vendorAddress/addition").try(:text),
                city: xml_part.at_xpath("vendorAddress/location").try(:text),
                street: xml_part.at_xpath("vendorAddress/street").try(:text),
                zip: xml_part.at_xpath("vendorAddress/zip").try(:text)
      Severity: Minor
      Found in app/models/record/poi_record.rb and 2 other locations - About 15 mins to fix
      app/models/record/event_record.rb on lines 117..122
      app/models/record/event_record.rb on lines 150..155

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

      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