robertgauld/osm

View on GitHub
lib/osm/model.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Model has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Model
    include ActiveModel::MassAssignmentSecurity if ActiveModel::VERSION::MAJOR < 4
    include ActiveAttr::Model

    SORT_BY = [:id]
Severity: Minor
Found in lib/osm/model.rb - About 2 hrs to fix

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

        def self.configure(options)
          raise ArgumentError, ":ttl must be a FixNum greater than 0" if options[:ttl] && !(options[:ttl].is_a?(Fixnum) && options[:ttl] > 0)
          raise ArgumentError, ":prepend_to_key must be a String" if options[:prepend_to_key] && !options[:prepend_to_key].is_a?(String)
          if options[:cache]
            [:exist?, :delete, :write, :read].each do |method|
    Severity: Minor
    Found in lib/osm/model.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 get_from_ids has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def self.get_from_ids(api, ids, key, arguments=[], options, get_all_method)
    Severity: Minor
    Found in lib/osm/model.rb - About 45 mins to fix

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

          def self.require_permission(api, to, on, section, options={})
      Severity: Minor
      Found in lib/osm/model.rb - About 35 mins to fix

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

            def self.has_permission?(api, to, on, section, options={})
        Severity: Minor
        Found in lib/osm/model.rb - About 35 mins to fix

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

              def self.user_has_permission?(api, to, on, section, options={})
          Severity: Minor
          Found in lib/osm/model.rb - About 35 mins to fix

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

                def self.require_ability_to(api, to, on, section, options={})
            Severity: Minor
            Found in lib/osm/model.rb - About 35 mins to fix

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

                  def self.api_has_permission?(api, to, on, section, options={})
              Severity: Minor
              Found in lib/osm/model.rb - About 35 mins to fix

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

                    def self.require_permission(api, to, on, section, options={})
                      section = Osm::Section.get(api, section.to_i, options) unless section.is_a?(Osm::Section)
                      section_name = section.try(:name)
                      unless user_has_permission?(api, to, on, section, options)
                        raise Osm::Forbidden, "Your OSM user does not have permission to #{to} on #{on} for #{section_name}."
                Severity: Minor
                Found in lib/osm/model.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

                There are no issues that match your filters.

                Category
                Status