Asana/ruby-asana

View on GitHub

Showing 24 of 24 total issues

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

  describe '#put' do
    it 'performs a PUT request against the Asana API' do
      api.on(:put, '/users/me', 'data' => { 'name' => 'John' }) do |response|
        response.body = { user: 'foo' }
      end
Severity: Major
Found in spec/asana/http_client_spec.rb and 1 other location - About 3 hrs to fix
spec/asana/http_client_spec.rb on lines 74..97

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 108.

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

  describe '#post' do
    it 'performs a POST request against the Asana API' do
      api.on(:post, '/users/me', 'data' => { 'name' => 'John' }) do |response|
        response.body = { user: 'foo' }
      end
Severity: Major
Found in spec/asana/http_client_spec.rb and 1 other location - About 3 hrs to fix
spec/asana/http_client_spec.rb on lines 46..69

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 108.

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 log_asana_change_headers has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def log_asana_change_headers(request_headers, response_headers)
      change_header_key = nil

      response_headers.each_key do |key|
        if key.downcase == 'asana-change'
Severity: Minor
Found in lib/asana/http_client.rb - About 2 hrs 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 log_asana_change_headers has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def log_asana_change_headers(request_headers, response_headers)
      change_header_key = nil

      response_headers.each_key do |key|
        if key.downcase == 'asana-change'
Severity: Major
Found in lib/asana/http_client.rb - About 2 hrs to fix

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

          def handle(num_retries=0, &request)
            request.call
          rescue Faraday::ClientError => e
            raise e unless e.response
            case e.response[:status]
    Severity: Minor
    Found in lib/asana/http_client/error_handling.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 handle has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def handle(num_retries=0, &request)
            request.call
          rescue Faraday::ClientError => e
            raise e unless e.response
            case e.response[:status]
    Severity: Minor
    Found in lib/asana/http_client/error_handling.rb - About 1 hr to fix

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

          it 'finds all unicorns by breed' do
            api.on(:get, '/unicorns?breed=magical&limit=20') do |response|
              response.body = { data: [laura_data] }
            end
      
      
      Severity: Major
      Found in spec/templates/unicorn_spec.rb and 2 other locations - About 45 mins to fix
      spec/templates/unicorn_spec.rb on lines 88..96
      spec/templates/unicorn_spec.rb on lines 140..148

      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 41.

      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 3 locations. Consider refactoring.
      Open

          it 'finds all unicorns by world in the URL' do
            api.on(:get, '/worlds/123/unicorns') do |response|
              response.body = { data: [john_data] }
            end
      
      
      Severity: Major
      Found in spec/templates/unicorn_spec.rb and 2 other locations - About 45 mins to fix
      spec/templates/unicorn_spec.rb on lines 88..96
      spec/templates/unicorn_spec.rb on lines 99..107

      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 41.

      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 3 locations. Consider refactoring.
      Open

          it 'finds all unicorns by world' do
            api.on(:get, '/unicorns?world=123&limit=20') do |response|
              response.body = { data: [john_data] }
            end
      
      
      Severity: Major
      Found in spec/templates/unicorn_spec.rb and 2 other locations - About 45 mins to fix
      spec/templates/unicorn_spec.rb on lines 99..107
      spec/templates/unicorn_spec.rb on lines 140..148

      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 41.

      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 each has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def each(&block)
              if block
                loop do
                  poll if @events.empty?
                  event = @events.shift
      Severity: Minor
      Found in lib/asana/resource_includes/events.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 post has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def post(resource_uri, body: {}, upload: nil, options: {})
            opts = options.reduce({}) do |acc, (k, v)|
              acc.tap do |hash|
                hash[:"opt_#{k}"] = v.is_a?(Array) ? v.join(',') : v
              end
      Severity: Minor
      Found in lib/asana/http_client.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

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

          specify '#post' do
            api.on(:post, '/tags', data: { name: 'work' }) do |response|
              response.body = { data: { foo: 'bar' } }
            end
      
      
      Severity: Minor
      Found in spec/asana/client_spec.rb and 1 other location - About 45 mins to fix
      spec/asana/client_spec.rb on lines 30..36

      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 39.

      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

          def delete(resource_uri, params: {}, options: {})
            opts = options.reduce({}) do |acc, (k, v)|
              acc.tap do |hash|
                hash[:"opt_#{k}"] = v.is_a?(Array) ? v.join(',') : v
              end
      Severity: Minor
      Found in lib/asana/http_client.rb and 1 other location - About 45 mins to fix
      lib/asana/http_client.rb on lines 50..56

      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 39.

      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

          def get(resource_uri, params: {}, options: {})
            opts = options.reduce({}) do |acc, (k, v)|
              acc.tap do |hash|
                hash[:"opt_#{k}"] = v.is_a?(Array) ? v.join(',') : v
              end
      Severity: Minor
      Found in lib/asana/http_client.rb and 1 other location - About 45 mins to fix
      lib/asana/http_client.rb on lines 115..121

      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 39.

      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

          specify '#put' do
            api.on(:put, '/tags/1', data: { name: 'work' }) do |response|
              response.body = { data: { foo: 'bar' } }
            end
      
      
      Severity: Minor
      Found in spec/asana/client_spec.rb and 1 other location - About 45 mins to fix
      spec/asana/client_spec.rb on lines 21..27

      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 39.

      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 perform_request has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def perform_request(method, resource_uri, body = {}, headers = {}, &request_config)
      Severity: Minor
      Found in lib/asana/http_client.rb - About 35 mins to fix

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

            context 'if there is only one page' do
              it 'iterates over that one' do
                collection = described_class.new([unicorns.take(5), {}],
                                                 type: unicorn_class,
                                                 client: client)
        Severity: Minor
        Found in spec/asana/resources/collection_spec.rb and 1 other location - About 25 mins to fix
        spec/asana/resources/collection_spec.rb on lines 81..86

        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 30.

        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

          describe '#elements' do
            it 'returns the current page of elements' do
              collection = described_class.new([unicorns.take(5), {}],
                                               type: unicorn_class,
                                               client: client)
        Severity: Minor
        Found in spec/asana/resources/collection_spec.rb and 1 other location - About 25 mins to fix
        spec/asana/resources/collection_spec.rb on lines 48..54

        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 30.

        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 os has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def os
                if RUBY_PLATFORM =~ /win32/ || RUBY_PLATFORM =~ /mingw/
                  'windows'
                elsif RUBY_PLATFORM =~ /linux/
                  'linux'
        Severity: Minor
        Found in lib/asana/http_client/environment_info.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

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

            def put(resource_uri, body: {}, options: {})
              opts = options.reduce({}) do |acc, (k, v)|
                acc.tap do |hash|
                  hash[:"opt_#{k}"] = v.is_a?(Array) ? v.join(',') : v
                end
        Severity: Minor
        Found in lib/asana/http_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