albertyw/apple_vpp

View on GitHub

Showing 42 of 42 total issues

Assignment Branch Condition size for refresh is too high. [24.76/15]
Open

    def refresh
      url = "#{SERVICE_URL}VPPServiceConfigSrv"
      resp = Request.submit url

      @associate_license_srv_url              = resp["associateLicenseSrvUrl"]
Severity: Minor
Found in lib/apple_vpp/url_service.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 manage_licenses_by_adam_id is too high. [22.23/15]
Open

    def manage_licenses_by_adam_id(params = {})
      require_params [:adam_id_str, :pricing_param], params

      unless params.has_key?(:associate_client_user_id_strs) ^
          params.has_key?(:associate_serial_numbers) ^
Severity: Minor
Found in lib/apple_vpp/client.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 check_for_errors is too high. [19.62/15]
Open

    def self.check_for_errors(json)
      if json["status"] == -1
        if json.include? "errorNumber"
          raise_error json["errorNumber"], json["errorMessage"]
        end
Severity: Minor
Found in lib/apple_vpp/request.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 check_for_errors has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def self.check_for_errors(json)
      if json["status"] == -1
        if json.include? "errorNumber"
          raise_error json["errorNumber"], json["errorMessage"]
        end
Severity: Minor
Found in lib/apple_vpp/request.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 require_params has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def require_params(param_name_array, params)
      param_name_array = [param_name_array] unless param_name_array.is_a? Array

      param_name_array.each do |param_names|
        param_names = [param_names] unless param_names.is_a?(Array)
Severity: Minor
Found in lib/apple_vpp/client.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 edit_user(params = {})
      require_params [[:user_id, :client_user_id_str]], params

      body = {
        "userId"          => params[:user_id],
Severity: Minor
Found in lib/apple_vpp/client.rb and 1 other location - About 30 mins to fix
lib/apple_vpp/client.rb on lines 109..120

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

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_user(params = {})
      require_params [[:user_id, :client_user_id_str]], params

      body = {
        "userId"          => params[:user_id],
Severity: Minor
Found in lib/apple_vpp/client.rb and 1 other location - About 30 mins to fix
lib/apple_vpp/client.rb on lines 55..66

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

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

Extra empty line detected at begin body end.
Open


      end while batch_token
Severity: Minor
Found in lib/apple_vpp/client.rb by rubocop

This cops checks if empty lines exist around the bodies of begin-end blocks.

Example:

# good

begin
  # ...
end

# bad

begin

  # ...

end

Do not use space inside array brackets.
Open

             9620, 9621, 9622, 9623, 9625, 9626, 9630 ]
Severity: Minor
Found in lib/apple_vpp/error.rb by rubocop

Checks that brackets used for array literals have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: space

# The `space` style enforces that array literals have
# surrounding space.

# bad
array = [a, b, c, d]

# good
array = [ a, b, c, d ]

Example: EnforcedStyle: no_space

# The `no_space` style enforces that array literals have
# no surrounding space.

# bad
array = [ a, b, c, d ]

# good
array = [a, b, c, d]

Example: EnforcedStyle: compact

# The `compact` style normally requires a space inside
# array brackets, with the exception that successive left
# or right brackets are collapsed together in nested arrays.

# bad
array = [ a, [ b, c ] ]

# good
array = [ a, [ b, c ]]

Use %i or %I for an array of symbols.
Open

      require_params [[:user_id, :client_user_id_str], [:adam_id, :license_id]], params
Severity: Minor
Found in lib/apple_vpp/client.rb by rubocop

This cop can check for array literals made up of symbols that are not using the %i() syntax.

Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

Example: EnforcedStyle: percent (default)

# good
%i[foo bar baz]

# bad
[:foo, :bar, :baz]

Example: EnforcedStyle: brackets

# good
[:foo, :bar, :baz]

# bad
%i[foo bar baz]

Avoid comma after the last item of a hash.
Open

        "apnToken"      => params[:apn_token],
Severity: Minor
Found in lib/apple_vpp/client.rb by rubocop

This cop checks for trailing comma in array and hash literals.

Example: EnforcedStyleForMultiline: consistent_comma

# bad
a = [1, 2,]

# good
a = [
  1, 2,
  3,
]

# good
a = [
  1,
  2,
]

Example: EnforcedStyleForMultiline: comma

# bad
a = [1, 2,]

# good
a = [
  1,
  2,
]

Example: EnforcedStyleForMultiline: no_comma (default)

# bad
a = [1, 2,]

# good
a = [
  1,
  2
]

Avoid comma after the last item of a hash.
Open

        "email"           => params[:email],
Severity: Minor
Found in lib/apple_vpp/client.rb by rubocop

This cop checks for trailing comma in array and hash literals.

Example: EnforcedStyleForMultiline: consistent_comma

# bad
a = [1, 2,]

# good
a = [
  1, 2,
  3,
]

# good
a = [
  1,
  2,
]

Example: EnforcedStyleForMultiline: comma

# bad
a = [1, 2,]

# good
a = [
  1,
  2,
]

Example: EnforcedStyleForMultiline: no_comma (default)

# bad
a = [1, 2,]

# good
a = [
  1,
  2
]

Extra empty line detected before the rescue.
Open


      rescue RestClient::ExceptionWithResponse => e
Severity: Minor
Found in lib/apple_vpp/request.rb by rubocop

This cops checks if empty lines exist around the bodies of begin sections. This cop doesn't check empty lines at begin body beginning/end and around method definition body. Style/EmptyLinesAroundBeginBody or Style/EmptyLinesAroundMethodBody can be used for this purpose.

Example:

# good

begin
  do_something
rescue
  do_something2
else
  do_something3
ensure
  do_something4
end

# good

def foo
  do_something
rescue
  do_something2
end

# bad

begin
  do_something

rescue

  do_something2

else

  do_something3

ensure

  do_something4
end

# bad

def foo
  do_something

rescue

  do_something2
end

Extra empty line detected at begin body beginning.
Open


        body = {
Severity: Minor
Found in lib/apple_vpp/client.rb by rubocop

This cops checks if empty lines exist around the bodies of begin-end blocks.

Example:

# good

begin
  # ...
end

# bad

begin

  # ...

end

Avoid comma after the last item of a hash.
Open

        since_modified_token: since_modified_token,
Severity: Minor
Found in lib/apple_vpp/client.rb by rubocop

This cop checks for trailing comma in array and hash literals.

Example: EnforcedStyleForMultiline: consistent_comma

# bad
a = [1, 2,]

# good
a = [
  1, 2,
  3,
]

# good
a = [
  1,
  2,
]

Example: EnforcedStyleForMultiline: comma

# bad
a = [1, 2,]

# good
a = [
  1,
  2,
]

Example: EnforcedStyleForMultiline: no_comma (default)

# bad
a = [1, 2,]

# good
a = [
  1,
  2
]

Freeze mutable objects assigned to constants.
Open

  VERSION = "3.4.1"
Severity: Minor
Found in lib/apple_vpp/version.rb by rubocop

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Example:

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

Extra empty line detected at begin body beginning.
Open


        body = {
Severity: Minor
Found in lib/apple_vpp/client.rb by rubocop

This cops checks if empty lines exist around the bodies of begin-end blocks.

Example:

# good

begin
  # ...
end

# bad

begin

  # ...

end

Add an empty line after magic comments.
Open

lib = File.expand_path("../lib", __FILE__)
Severity: Minor
Found in apple_vpp.gemspec by rubocop

Checks for a newline after the final magic comment.

Example:

# good
# frozen_string_literal: true

# Some documentation for Person
class Person
  # Some code
end

# bad
# frozen_string_literal: true
# Some documentation for Person
class Person
  # Some code
end

Extra empty line detected at begin body end.
Open


      end while batch_token
Severity: Minor
Found in lib/apple_vpp/client.rb by rubocop

This cops checks if empty lines exist around the bodies of begin-end blocks.

Example:

# good

begin
  # ...
end

# bad

begin

  # ...

end

Extra empty line detected after the rescue.
Open


        unless e.response.code == 503
Severity: Minor
Found in lib/apple_vpp/request.rb by rubocop

This cops checks if empty lines exist around the bodies of begin sections. This cop doesn't check empty lines at begin body beginning/end and around method definition body. Style/EmptyLinesAroundBeginBody or Style/EmptyLinesAroundMethodBody can be used for this purpose.

Example:

# good

begin
  do_something
rescue
  do_something2
else
  do_something3
ensure
  do_something4
end

# good

def foo
  do_something
rescue
  do_something2
end

# bad

begin
  do_something

rescue

  do_something2

else

  do_something3

ensure

  do_something4
end

# bad

def foo
  do_something

rescue

  do_something2
end
Severity
Category
Status
Source
Language