bayetech/ll_pay

View on GitHub

Showing 67 of 67 total issues

Method has too many lines. [18/10]
Open

  def self.request(verb, url, params = {}, options = {})
    case verb.to_sym
    when :post
      @http_response = HTTP.post(url, json: params)
    when :get
Severity: Minor
Found in lib/ll_pay.rb by rubocop

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

Method has too many lines. [17/10]
Open

    def securitypay_pay_json(params, options = {})
      LlPay::Utils.check_required_params(params, SECURITY_PAY_REQUIRED_PARAMS)
      params = LlPay::Utils.stringify_keys(params)
      options = LlPay::Utils.stringify_keys(options)

Severity: Minor
Found in lib/ll_pay/service.rb by rubocop

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

Method has too many lines. [17/10]
Open

    def refund_order(params, options = {})
      LlPay::Utils.check_required_params(params, REFUND_ORDER_PARAMS)
      params = LlPay::Utils.stringify_keys(params)
      options = LlPay::Utils.stringify_keys(options)

Severity: Minor
Found in lib/ll_pay/refund_order.rb by rubocop

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

Assignment Branch Condition size for refund_order is too high. [21.26/15]
Open

    def refund_order(params, options = {})
      LlPay::Utils.check_required_params(params, REFUND_ORDER_PARAMS)
      params = LlPay::Utils.stringify_keys(params)
      options = LlPay::Utils.stringify_keys(options)

Severity: Minor
Found in lib/ll_pay/refund_order.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 securitypay_pay_json is too high. [21.26/15]
Open

    def securitypay_pay_json(params, options = {})
      LlPay::Utils.check_required_params(params, SECURITY_PAY_REQUIRED_PARAMS)
      params = LlPay::Utils.stringify_keys(params)
      options = LlPay::Utils.stringify_keys(options)

Severity: Minor
Found in lib/ll_pay/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

Method has too many lines. [15/10]
Open

    def self.generate(params, options = {})
      params = LlPay::Utils.stringify_keys(params)
      options = LlPay::Utils.stringify_keys(options)

      sign_type = params[:sign_type]
Severity: Minor
Found in lib/ll_pay/sign.rb by rubocop

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

Method has too many lines. [14/10]
Open

    def self.verify?(params, options = {})
      params = LlPay::Utils.stringify_keys(params)
      options = LlPay::Utils.stringify_keys(options)

      sign_type = params[:sign_type]
Severity: Minor
Found in lib/ll_pay/sign.rb by rubocop

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

Method has too many lines. [12/10]
Open

    def refund_order_query(params, options = {})
      params = LlPay::Utils.stringify_keys(params)
      options = LlPay::Utils.stringify_keys(options)

      params[:sign_type] = params[:sign_type] || LlPay.sign_type
Severity: Minor
Found in lib/ll_pay/refund_order.rb by rubocop

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

Method request has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def self.request(verb, url, params = {}, options = {})
    case verb.to_sym
    when :post
      @http_response = HTTP.post(url, json: params)
    when :get
Severity: Minor
Found in lib/ll_pay.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

      sign_params = { busi_partner: params[:busi_partner],
                      dt_order: params[:dt_order],
                      money_order: params[:money_order],
                      no_order: params[:no_order],
                      notify_url: params[:notify_url],
Severity: Minor
Found in lib/ll_pay/service.rb and 1 other location - About 40 mins to fix
lib/ll_pay/refund_order.rb on lines 12..21

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

      sign_params = { oid_partner: params[:oid_partner],
                      sign_type: params[:sign_type],
                      no_refund: params[:no_refund],
                      dt_refund: params[:dt_refund],
                      money_refund: params[:money_refund],
Severity: Minor
Found in lib/ll_pay/refund_order.rb and 1 other location - About 40 mins to fix
lib/ll_pay/service.rb on lines 15..24

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

Use 2 spaces for indentation in a heredoc by using some library(e.g. ActiveSupport's String#strip_heredoc).
Open

-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCSS/DiwdCf/aZsxxcacDnooGph3d2JOj5GXWi+
q3gznZauZjkNP8SKl3J2liP0O6rU/Y/29+IUe+GTMhMOFJuZm1htAtKiu5ekW0GlBMWxf4FPkYlQ
kPE0FtaoMP3gYfh+OwI+fIRrpW3ySn3mScnc6Z700nU/VYrRkfcSCbSnRwIDAQAB
-----END PUBLIC KEY-----
Severity: Minor
Found in lib/ll_pay.rb by rubocop

This cops checks the indentation of the here document bodies. The bodies are indented one step. In Ruby 2.3 or newer, squiggly heredocs (<<~) should be used. If you use the older rubies, you should introduce some library to your project (e.g. ActiveSupport, Powerpack or Unindent). Note: When Metrics/LineLength's AllowHeredoc is false(not default), this cop does not add any offenses for long here documents to avoid Metrics/LineLength's offenses.

Example:

# bad
<<-RUBY
something
RUBY

# good
# When EnforcedStyle is squiggly, bad code is auto-corrected to the
# following code.
<<~RUBY
  something
RUBY

# good
# When EnforcedStyle is active_support, bad code is auto-corrected to
# the following code.
<<-RUBY.strip_heredoc
  something
RUBY

Line is too long. [95/80]
Open

      params[:oid_partner] = params[:oid_partner] || options[:oid_partner] || LlPay.oid_partner
Severity: Minor
Found in lib/ll_pay/refund_order.rb by rubocop

Unnecessary utf-8 encoding comment.
Open

# coding: utf-8
Severity: Minor
Found in ll_pay.gemspec by rubocop

Use only ascii symbols in comments.
Open

    attr_accessor :rsa_pri_key # 私钥
Severity: Minor
Found in lib/ll_pay.rb by rubocop

This cop checks for non-ascii (non-English) characters in comments. You could set an array of allowed non-ascii chars in AllowedChars attribute (empty by default).

Example:

# bad
# Translates from English to 日本語。

# good
# Translates from English to Japanese

Use a guard clause instead of wrapping the code inside a conditional expression.
Open

    if @http_response.code == 200
Severity: Minor
Found in lib/ll_pay.rb by rubocop

Use a guard clause instead of wrapping the code inside a conditional expression

Example:

# bad
def test
  if something
    work
  end
end

# good
def test
  return unless something
  work
end

# also good
def test
  work if something
end

# bad
if something
  raise 'exception'
else
  ok
end

# good
raise 'exception' if something
ok

Extra empty line detected at module body beginning.
Open


    SECURITY_PAY_REQUIRED_PARAMS = %w(busi_partner dt_order info_order money_order name_goods no_order notify_url oid_partner risk_item sign_type valid_order)
Severity: Minor
Found in lib/ll_pay/service.rb by rubocop

This cops checks if empty lines around the bodies of modules match the configuration.

Example: EnforcedStyle: empty_lines

# good

module Foo

  def bar
    # ...
  end

end

Example: EnforcedStyle: emptylinesexcept_namespace

# good

module Foo
  module Bar

    # ...

  end
end

Example: EnforcedStyle: emptylinesspecial

# good
module Foo

  def bar; end

end

Example: EnforcedStyle: noemptylines (default)

# good

module Foo
  def bar
    # ...
  end
end

Line is too long. [158/80]
Open

    SECURITY_PAY_REQUIRED_PARAMS = %w(busi_partner dt_order info_order money_order name_goods no_order notify_url oid_partner risk_item sign_type valid_order)
Severity: Minor
Found in lib/ll_pay/service.rb by rubocop

Line is too long. [87/80]
Open

      params[:sign_type] = params[:sign_type] || options[:sign_type] || LlPay.sign_type
Severity: Minor
Found in lib/ll_pay/service.rb by rubocop

Missing top-level class documentation comment.
Open

    class RSA
Severity: Minor
Found in lib/ll_pay/sign/rsa.rb by rubocop

This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

Example:

# bad
class Person
  # ...
end

# good
# Description/Explanation of Person class
class Person
  # ...
end
Severity
Category
Status
Source
Language