Showing 26 of 32 total issues

Method selector_option has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def selector_option(label, param, value, default=false, class_name=nil)
      class_name = value unless class_name
      selected = params[param] == value.to_s || (params[param].nil? && default)
      "<a href=\"?#{param}=#{value}\" class=\"option #{class_name}#{' selected' if selected}\" data-selector-param=\"#{param}\" data-selector-value=\"#{value}\" #{'data-selector-default="true"' if default}>#{label}</a>".html_safe

Severity: Minor
Found in app/helpers/concerns/components_helper.rb - About 25 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 map_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def map_options(obj)
      obj_type = object_type obj
      geojsonTileURL = obj_type == :map ? "/maps/#{obj.id}/tile/{z}/{x}/{y}" : "/geo_data/tile/{z}/{x}/{y}"
      opts = {
        layers: obj.try(:layers_values),
Severity: Minor
Found in app/helpers/concerns/components_helper.rb - About 25 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 cleaned_relations_attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

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

  def save_object(obj, params_hash)
    obj.assign_attributes(params_hash)
    changes = obj.changes
    if obj.valid? && obj.save
      obj_name = obj.class.name.underscore
Severity: Minor
Found in app/controllers/concerns/utils.rb - About 25 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 featured= has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def featured=(value)
      if value == true
        Featured.find_or_create_by(_featured_params)
      elsif value == false
        featured = Featured.where(_featured_params).first
Severity: Minor
Found in app/models/concerns/featurable.rb - About 25 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 serialized_as has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def self.serialized_as(format, ids=nil)
      collection = (ids ? where(id: ids) : all).map { |obj| active_model_serializer.new(obj) }
      hashs_collection = collection.map &:serializable_hash
      case format
        when :json    then hashs_collection.to_json
Severity: Minor
Found in app/models/concerns/exportable.rb - About 25 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