Showing 32 of 32 total issues

File mootiro_importer.rb has 343 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module MootiroImporter

  module_function

  REDIS_HOST = ENV['MOOTIRO_REDIS_HOST'] || '10.0.2.2'
Severity: Minor
Found in lib/mootiro_importer.rb - About 4 hrs to fix

    Method select_tools has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

      def select_tools
        case type
        when 'user'
          current_user == object ? [:edit, :settings] : [:star, :flag]
        when 'geo_data'
    Severity: Minor
    Found in app/presenters/toolbar_presenter.rb - About 3 hrs 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 cleaned_layers_attributes has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

      def cleaned_layers_attributes(_params)
        _attrs = JSON.parse _params[:layers_attributes]
        _attrs.map do |layer|
          OpenStruct.new(
            id:           layer['id'].blank? ? nil : layer['id'].to_i,
    Severity: Minor
    Found in app/controllers/concerns/utils.rb - About 2 hrs 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 build_map has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

      def build_map(d, &blk)
        Rails.logger.debug "Building Map... "
        additional_info = {}
        additional_info.merge! short_description: d[:short_description] unless d[:short_description].blank?
    
    
    Severity: Minor
    Found in lib/mootiro_importer.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 build_user has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

      def build_user(d, &blk)
        Rails.logger.debug "Building User... "
        user = User.new(
          name: d[:name],
          email: d[:email],
    Severity: Minor
    Found in lib/mootiro_importer.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 testimonials has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def testimonials
        # MOCKED
        [
          {
            :name         => 'aldeias-infantis',
    Severity: Minor
    Found in app/helpers/pages_helper.rb - About 1 hr to fix

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

          def remove_mapping_to(target_model)
            target_ref = target_model.name.underscore
            if target = target_model.find_by(id: params[target_ref.to_sym])
              _mapping, msg = delete_mapping target
              count_method = :"#{target_ref.pluralize}_count"
      Severity: Major
      Found in app/controllers/objects_controller.rb and 1 other location - About 1 hr to fix
      app/controllers/objects_controller.rb on lines 93..102

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

      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

          def add_mapping_to(target_model)
            target_ref = target_model.name.underscore
            if target = target_model.find_by(id: params[target_ref.to_sym])
              _mapping, msg = create_mapping target
              count_method = :"#{target_ref.pluralize}_count"
      Severity: Major
      Found in app/controllers/objects_controller.rb and 1 other location - About 1 hr to fix
      app/controllers/objects_controller.rb on lines 105..114

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

      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 build_map has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def build_map(d, &blk)
          Rails.logger.debug "Building Map... "
          additional_info = {}
          additional_info.merge! short_description: d[:short_description] unless d[:short_description].blank?
      
      
      Severity: Minor
      Found in lib/mootiro_importer.rb - About 1 hr to fix

        Method use_cases has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def use_cases
            # MOCKED
            [
              {
                :href  => '#use_cases#jornalismo_de_dados',
        Severity: Minor
        Found in app/helpers/pages_helper.rb - About 1 hr to fix

          Method remove_geometrycollection has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def remove_geometrycollection(location)
              Rails.logger.debug "Removing GeometryCollection... "
              return nil if location.eql? 'EMPTY GEOMETRYCOLLECTION'
              return location unless location.include? "GEOMETRYCOLLECTION"
          
          
          Severity: Minor
          Found in lib/mootiro_importer.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 remove_geometrycollection has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def remove_geometrycollection(location)
              Rails.logger.debug "Removing GeometryCollection... "
              return nil if location.eql? 'EMPTY GEOMETRYCOLLECTION'
              return location unless location.include? "GEOMETRYCOLLECTION"
          
          
          Severity: Minor
          Found in lib/mootiro_importer.rb - About 1 hr to fix

            Method cleaned_relation_metadata has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def cleaned_relation_metadata(m)
                OpenStruct.new(
                  description: m['description'].blank? ? nil : m['description'],
                  start_date:  m['start_date'].blank? ? nil : Date.parse(m['start_date']),
                  end_date:    m['end_date'].blank?   ? nil : Date.parse(m['end_date']),
            Severity: Minor
            Found in app/controllers/concerns/utils.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 build_relation has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def build_relation(d, &blk)
                Rails.logger.debug "Building Relation... "
                model1 = model_from_oid(d[:oid_1])
                model2 = model_from_oid(d[:oid_2])
                return false unless model1 && model2
            Severity: Minor
            Found in lib/mootiro_importer.rb - About 1 hr to fix

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

                  def link_to_modal(body, url, options={})
                    html_attrs = hash_to_attributes(options[:html]) if options[:html]
                    modal_attrs = options.except(:html).to_json
                    components = ["modal"] + (options[:login_required] ? ["loginRequired"] : [])
              
              
              Severity: Major
              Found in app/helpers/concerns/components_helper.rb and 1 other location - About 1 hr to fix
              app/helpers/concerns/components_helper.rb on lines 27..32

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

                  def button_to_modal(body, url, options={})
                    html_attrs = hash_to_attributes(options[:html]) if options[:html]
                    modal_attrs = options.except(:html).to_json
                    components = ["modal"] + (options[:login_required] ? ["loginRequired"] : [])
              
              
              Severity: Major
              Found in app/helpers/concerns/components_helper.rb and 1 other location - About 1 hr to fix
              app/helpers/concerns/components_helper.rb on lines 15..20

              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

              Method controls has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                def controls
                  case control_type_
                  when :follow_button
                    return ctx.render 'shared/follow_button', object: object unless object == ctx.current_user
                  when :remove_button
              Severity: Minor
              Found in app/presenters/list_item_presenter.rb - 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

              Method build_geo_data has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                def build_geo_data(d, &blk)
                  Rails.logger.debug "Building GeoData... "
                  additional_info = {}
                  additional_info.merge! short_description: d[:short_description] unless d[:short_description].blank?
                  additional_info.merge! creator: d[:creator] unless d[:creator].blank?
              Severity: Minor
              Found in lib/mootiro_importer.rb - 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

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

                  def selector_option(label, param, value, default=false, class_name=nil)
              Severity: Minor
              Found in app/helpers/concerns/components_helper.rb - About 35 mins to fix

                Method parse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def parse(geojson, opts={})
                    return nil if geojson.nil? || geojson.try(:empty?)
                    geojson_hash = geojson.is_a?(Hash) ? geojson : JSON.parse(geojson)
                    decoded_geojson = RGeo::GeoJSON.decode(geojson_hash)
                    decoded_geojson = decoded_geojson.first if decoded_geojson.is_a? Enumerable
                Severity: Minor
                Found in lib/geo_json.rb - About 35 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