gini/gini-api-ruby

View on GitHub

Showing 3 of 3 total issues

Method initialize has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def initialize(api, opts)
        # Initialize client. max_redirect is required as oauth2 will otherwise redirect to location from header (localhost)
        # https://github.com/intridea/oauth2/blob/master/lib/oauth2/client.rb#L100
        # Our code is encoded in the URL and has to be parsed from there.
        client = OAuth2::Client.new(
Severity: Minor
Found in lib/gini-api/oauth.rb - About 1 hr to fix

    Method update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def update(from_data = nil)
            data = {}
    
            if from_data.nil?
              response = @api.request(:get, @location)
    Severity: Minor
    Found in lib/gini-api/document.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

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

          def register_parser
            OAuth2::Response.register_parser(:gini_json, [version_header(:json)[:accept]]) do |body|
              MultiJson.load(body, symbolize_keys: true) rescue body
            end
            OAuth2::Response.register_parser(:gini_xml, [version_header(:xml)[:accept]]) do |body|
    Severity: Minor
    Found in lib/gini-api/client.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