authy/authy-ruby

View on GitHub

Showing 4 of 4 total issues

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

    def self.send_approval_request(params)
      user_id           = params.delete(:id) || params.delete('id')
      message           = (params.delete(:message) || params.delete('message')).to_s
      details           = params.delete(:details) || params.delete('details')
      hidden_details    = params.delete(:hidden_details) || params.delete('hidden_details')
Severity: Minor
Found in lib/authy/onetouch.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 escape_query has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def escape_query(query, namespace = nil) # :nodoc:
        pairs = []

        query.each do |attr, value|
          left = namespace ? "#{namespace}[#{attr.to_s}]" : attr.to_s
Severity: Minor
Found in lib/authy/url_helpers.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 clean_logos! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def self.clean_logos!(logos)
      return if logos.nil? # Allow nil logos

      raise "Array expected. Got #{logos.class}" unless logos.is_a? Array
      logos = logos.map do |logo|
Severity: Minor
Found in lib/authy/onetouch.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 verify has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def self.verify(params)
      token = params.delete(:token) || params.delete("token")
      user_id = params.delete(:id) || params.delete("id")

      return invalid_response("Token format is invalid") unless token_is_safe?(token)
Severity: Minor
Found in lib/authy/api.rb - About 45 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