jungomi/coach_client

View on GitHub

Showing 39 of 39 total issues

Class has too many lines. [167/150]
Open

  class Partnership < CoachClient::Resource
    # @return [Integer]
    attr_reader :id, :datecreated

    # @return [Boolean]
Severity: Minor
Found in lib/coach_client/partnership.rb by rubocop

This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for update is too high. [44.42/20]
Open

    def update
      fail CoachClient::NotFound.new(self), 'Entry not found' if @id.nil?
      response = CoachClient::Request.get(url, username: user.username,
                                          password: user.password)
      tag = "entry#{@subscription.sport}"
Severity: Minor
Found in lib/coach_client/entry.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for update is too high. [37.5/20]
Open

    def update(size: 20, start: 0, all: false)
      response = {}
      if all
        start = 0
        size = @client.max_size
Severity: Minor
Found in lib/coach_client/user.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for initialize is too high. [30.38/20]
Open

    def initialize(client, subscription, info = {})
      super(client)
      @subscription = subscription
      @id = info[:id]
      @publicvisible = info[:publicvisible]
Severity: Minor
Found in lib/coach_client/entry.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for update is too high. [26.72/20]
Open

    def update(user, size: 20, start: 0, all: false)
      response = {}
      if all
        start = 0
        size = @client.max_size
Severity: Minor
Found in lib/coach_client/subscription.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for update is too high. [25.08/20]
Open

    def update
      response = begin
                   CoachClient::Request.get(url, username: @user1.username,
                                            password: @user1.password)
                 rescue CoachClient::Exception
Severity: Minor
Found in lib/coach_client/partnership.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

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

    def self.put(url, username: nil, password: nil, payload:, **header)
      header.merge!(DEFAULT_HEADER)
      begin
        response = RestClient::Request.execute(method: :put, url: url,
                                               user: username,
Severity: Major
Found in lib/coach_client/request.rb and 1 other location - About 1 hr to fix
lib/coach_client/request.rb on lines 63..78

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

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 self.post(url, username: nil, password: nil, payload:, **header)
      header.merge!(DEFAULT_HEADER)
      begin
        response = RestClient::Request.execute(method: :post, url: url,
                                               user: username,
Severity: Major
Found in lib/coach_client/request.rb and 1 other location - About 1 hr to fix
lib/coach_client/request.rb on lines 37..52

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

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

Assignment Branch Condition size for list is too high. [20.86/20]
Open

    def self.list(client, size: 20, start: 0, all: false)
      list = []
      if all
        total = self.total(client)
        start = 0
Severity: Minor
Found in lib/coach_client/partnership.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method list has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def self.list(client, size: 20, start: 0, all: false)
      userlist = []
      if all
        total = self.total(client)
        start = 0
Severity: Minor
Found in lib/coach_client/user.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 list has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def self.list(client, size: 20, start: 0, all: false)
      list = []
      if all
        total = self.total(client)
        start = 0
Severity: Minor
Found in lib/coach_client/partnership.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

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

    def self.get(url, username: nil, password: nil, **header)
      header.merge!(DEFAULT_HEADER)
      begin
        response = RestClient::Request.execute(method: :get, url: url,
                                               user: username,
Severity: Major
Found in lib/coach_client/request.rb and 1 other location - About 1 hr to fix
lib/coach_client/request.rb on lines 88..100

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

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 self.delete(url, username: nil, password: nil, **header)
      header.merge!(DEFAULT_HEADER)
      begin
        response = RestClient::Request.execute(method: :delete, url: url,
                                               user: username,
Severity: Major
Found in lib/coach_client/request.rb and 1 other location - About 1 hr to fix
lib/coach_client/request.rb on lines 14..26

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

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 update has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def update(size: 20, start: 0, all: false)
      response = {}
      if all
        start = 0
        size = @client.max_size
Severity: Minor
Found in lib/coach_client/user.rb - About 1 hr to fix

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

        def update(size: 20, start: 0, all: false)
          response = {}
          if all
            start = 0
            size = @client.max_size
    Severity: Minor
    Found in lib/coach_client/user.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 save has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def save
          unless operational?
            propose unless @user1_confirmed
            return confirm
          end
    Severity: Minor
    Found in lib/coach_client/partnership.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 update has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def update(user, size: 20, start: 0, all: false)
          response = {}
          if all
            start = 0
            size = @client.max_size
    Severity: Minor
    Found in lib/coach_client/subscription.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

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

        def propose
          response = CoachClient::Request.put(url, username: @user1.username,
                                              password: @user1.password,
                                              payload: payload,
                                              content_type: :xml)
    Severity: Minor
    Found in lib/coach_client/partnership.rb and 1 other location - About 40 mins to fix
    lib/coach_client/partnership.rb on lines 187..196

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

    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 confirm
          response = CoachClient::Request.put(url, username: @user2.username,
                                              password: @user2.password,
                                              payload: payload,
                                              content_type: :xml)
    Severity: Minor
    Found in lib/coach_client/partnership.rb and 1 other location - About 40 mins to fix
    lib/coach_client/partnership.rb on lines 168..177

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

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

        def to_h
          hash = {}
          instance_variables.each do |var|
            next if var.to_s == '@client'
            value = instance_variable_get(var)
    Severity: Minor
    Found in lib/coach_client/resource.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