ikuseiGmbH/smart-village-app-converter-xml2json

View on GitHub

Showing 20 of 24 total issues

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

      Function exports has 78 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function(api) {
        var validEnv = ['development', 'test', 'production']
        var currentEnv = api.env()
        var isDevelopmentEnv = api.env('development')
        var isProductionEnv = api.env('production')
      Severity: Major
      Found in babel.config.js - About 3 hrs to fix

        Method weekday has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.weekday(day)
            return "" if day.blank?
        
            case day
            when "monday"
        Severity: Minor
        Found in app/services/translation.rb - About 1 hr to fix

          Method get_request has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

            def get_request(content_type_xml = false, pem = nil, password = nil)
              uri = Addressable::URI.parse(@uri.strip).normalize
          
              uri.query = [uri.query, URI.encode_www_form(@params)].join("&") if @params && @params.any?
          
          
          Severity: Minor
          Found in app/services/api_request_service.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_media_content has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def parse_media_content(event)
              image_data = []
          
              if event.at_xpath("IMAGELINK_XL").try(:text).present?
                image_data << {
          Severity: Minor
          Found in app/models/record/event_record.rb - About 1 hr to fix

            Method get_request has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def get_request(content_type_xml = false, pem = nil, password = nil)
                uri = Addressable::URI.parse(@uri.strip).normalize
            
                uri.query = [uri.query, URI.encode_www_form(@params)].join("&") if @params && @params.any?
            
            
            Severity: Minor
            Found in app/services/api_request_service.rb - About 1 hr to fix

              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

              Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def initialize(uri, login = nil, password = nil, params = {}, headers = {})
              Severity: Minor
              Found in app/services/api_request_service.rb - About 35 mins to fix

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

                    {
                      phone: event.at_xpath("E_LOC_TEL").try(:text),
                      fax: event.at_xpath("E_LOC_FAX").try(:text),
                      email: event.at_xpath("E_LOC_EMAIL").try(:text),
                      web_urls: [
                Severity: Minor
                Found in app/models/record/event_record.rb and 1 other location - About 20 mins to fix
                app/models/record/event_record.rb on lines 156..165

                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

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

                      contact: {
                        phone: event.at_xpath("E_KONTAKT_TEL").try(:text),
                        fax: event.at_xpath("E_KONTAKT_FAX").try(:text),
                        email: event.at_xpath("E_KONTAKT_EMAIL").try(:text),
                        web_urls: [
                Severity: Minor
                Found in app/models/record/event_record.rb and 1 other location - About 20 mins to fix
                app/models/record/event_record.rb on lines 132..141

                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

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

                    if event.at_xpath("IMAGELINK_3_XL").try(:text).present?
                      image_data << {
                        content_type: "image",
                        source_url: {
                          url: event.at_xpath("IMAGELINK_3_XL").try(:text)
                Severity: Minor
                Found in app/models/record/event_record.rb and 2 other locations - About 15 mins to fix
                app/models/record/event_record.rb on lines 180..186
                app/models/record/event_record.rb on lines 190..196

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

                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

                    if event.at_xpath("IMAGELINK_XL").try(:text).present?
                      image_data << {
                        content_type: "image",
                        source_url: {
                          url: event.at_xpath("IMAGELINK_XL").try(:text)
                Severity: Minor
                Found in app/models/record/event_record.rb and 2 other locations - About 15 mins to fix
                app/models/record/event_record.rb on lines 190..196
                app/models/record/event_record.rb on lines 200..206

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

                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

                    if event.at_xpath("IMAGELINK_2_XL").try(:text).present?
                      image_data << {
                        content_type: "image",
                        source_url: {
                          url: event.at_xpath("IMAGELINK_2_XL").try(:text)
                Severity: Minor
                Found in app/models/record/event_record.rb and 2 other locations - About 15 mins to fix
                app/models/record/event_record.rb on lines 180..186
                app/models/record/event_record.rb on lines 200..206

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

                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

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

                      address: {
                        addition: event.at_xpath("E_KONTAKT_NAME").try(:text),
                        street: event.at_xpath("E_KONTAKT_STRASSE").try(:text),
                        zip: event.at_xpath("E_KONTAKT_PLZ").try(:text),
                        city: event.at_xpath("E_KONTAKT_ORT").try(:text)
                Severity: Minor
                Found in app/models/record/event_record.rb and 2 other locations - About 15 mins to fix
                app/models/record/event_record.rb on lines 117..122
                app/models/record/poi_record.rb on lines 301..306

                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

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

                    return_value = {
                      addition: event.at_xpath("E_LOC_NAME").try(:text),
                      street: event.at_xpath("E_LOC_STRASSE").try(:text),
                      zip: event.at_xpath("E_LOC_PLZ").try(:text),
                      city: event.at_xpath("E_LOC_ORT").try(:text)
                Severity: Minor
                Found in app/models/record/event_record.rb and 2 other locations - About 15 mins to fix
                app/models/record/event_record.rb on lines 150..155
                app/models/record/poi_record.rb on lines 301..306

                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

                Severity
                Category
                Status
                Source
                Language