zaeznet/realpush-ruby

View on GitHub

Showing 4 of 4 total issues

Method included has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def self.included(base)
        base.class_eval do

          attr_reader :token

Severity: Major
Found in lib/realpush/api/base.rb - About 2 hrs to fix

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

        def url=(str)
          regex = /^(?<scheme>http|https):\/\/((?<app_id>[\d-]+)(:(?<privatekey>[\w-]+){1})?@)?(?<hostname>[\w\.-]+)(:(?<port>[\d]+))?/
          match = str.match regex
          @scheme     = match[:scheme]     unless match[:scheme].nil?
          self.encrypted= true if scheme == 'https'
    Severity: Minor
    Found in lib/realpush/client.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def initialize(client, verb, uri, params={}, body = nil)
    Severity: Minor
    Found in lib/realpush/request.rb - About 35 mins to fix

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

          def initialize(client, verb, uri, params={}, body = nil)
            @client, @verb, @uri, @params = client, verb, uri, params
      
            raise ConfigurationError, "Invalid verb ('#{verb}')" unless %w{GET POST}.include? verb.to_s.upcase
            raise ConfigurationError, "Invalid client #{client.inspect}" unless client.is_a? Client
      Severity: Minor
      Found in lib/realpush/request.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