artsy/artsy-ruby-client

View on GitHub

Showing 14 of 14 total issues

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

        def when
          starts = DateTime.parse(self[:start_at])
          ends = DateTime.parse(self[:end_at])

          starts_month = starts.strftime("%b")
Severity: Minor
Found in lib/artsy/client/domain/show.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 on_complete has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def on_complete(env)
          if (env[:response_headers][:content_type] || "").start_with? 'application/json'
            if respond_to?(:parse)
              env[:body] = parse(env[:body]) unless [204, 301, 302, 304].include?(env[:status])
            end
Severity: Minor
Found in lib/artsy/client/response/parse_json.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 request_setup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def request_setup(method, path, params)
        proc do |request|
          if @access_token
            request.headers["X-ACCESS-TOKEN"] = @access_token
          elsif @xapp_token
Severity: Minor
Found in lib/artsy/client/instance.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 object_from_response has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

        def object_from_response(instance, klass, request_method, path, options = {})
Severity: Minor
Found in lib/artsy/client/api/parse.rb - About 35 mins to fix

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

            def objects_from_response_feed(instance, klass, request_method, path, options = {})
    Severity: Minor
    Found in lib/artsy/client/api/parse.rb - About 35 mins to fix

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

              def objects_from_response(instance, klass, request_method, path, options = {})
      Severity: Minor
      Found in lib/artsy/client/api/parse.rb - About 35 mins to fix

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

              def authenticate!
                configure!
                validate_credentials!
                if @user_email && @user_password && @client_id && @client_secret
                  @logger.debug "GET /oauth2/access_token?client_id=#{CGI.escape(@client_id)}&client_secret=#{CGI.escape(@client_secret)}&email=#{CGI.escape(@user_email)}&password=********&grant_type=credentials" if @logger
        Severity: Minor
        Found in lib/artsy/client/instance.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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          module Client
            module API
              module Show
                include Artsy::Client::API::Parse
        
        
        Severity: Minor
        Found in lib/artsy/client/api/show.rb and 1 other location - About 35 mins to fix
        lib/artsy/client/api/feature.rb on lines 2..18

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 34.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          module Client
            module API
              module Feature
                include Artsy::Client::API::Parse
        
        
        Severity: Minor
        Found in lib/artsy/client/api/feature.rb and 1 other location - About 35 mins to fix
        lib/artsy/client/api/show.rb on lines 2..18

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 34.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

              def validate_credentials!
                if @access_token
                  # access token gives a user login
                elsif @client_id && @client_secret
                  # client id and secret give access to an xapp token
        Severity: Minor
        Found in lib/artsy/client/configurable.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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

          puts "#{show.name} at #{show.partner.name}"
          show.artworks(size: 2).each do |artwork|
            puts "  #{artwork.title}, #{artwork.date}"
        Severity: Minor
        Found in examples/shows_sample.rb and 1 other location - About 20 mins to fix
        examples/shows.rb on lines 9..11

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 28.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

          puts "#{show.name} at #{show.partner.name}"
          show.artworks(size: 2).each do |artwork|
            puts "  #{artwork.title}, #{artwork.date}"
        Severity: Minor
        Found in examples/shows.rb and 1 other location - About 20 mins to fix
        examples/shows_sample.rb on lines 9..11

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 28.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          module Client
            module API
              module SearchQuery
                include Artsy::Client::API::Parse
        
        
        Severity: Minor
        Found in lib/artsy/client/api/search_query.rb and 1 other location - About 15 mins to fix
        lib/artsy/client/api/match.rb on lines 2..11

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 25.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          module Client
            module API
              module Match
                include Artsy::Client::API::Parse
        
        
        Severity: Minor
        Found in lib/artsy/client/api/match.rb and 1 other location - About 15 mins to fix
        lib/artsy/client/api/search_query.rb on lines 2..11

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 25.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Severity
        Category
        Status
        Source
        Language