rakuten-ws/rws-ruby-sdk

View on GitHub

Showing 165 of 165 total issues

Assignment Branch Condition size for initialize is too high. [23.39/15]
Open

        def initialize(data, parent=nil)
          @parent = parent
          class_data = data
          @params, @children = *(case class_data
                              when Array

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. [17/10]
Open

        def initialize(data, parent=nil)
          @parent = parent
          class_data = data
          @params, @children = *(case class_data
                              when Array

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. [16/10]
Open

    def order(options)
      new_params = params.dup
      if options.is_a? Hash
        key, sort_order = *options.to_a.last
        key = key.to_s.to_camel

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. [16/10]
Open

      def attribute(*attribute_names)
        attribute_names.each do |attribute_name|
          attribute_name = attribute_name.to_s
          method_name = attribute_name.to_snake
          method_name = method_name.sub(/^#{resource_name}_(\w+)$/, '\1')
Severity: Minor
Found in lib/rakuten_web_service/resource.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.

Cyclomatic complexity for find_resource_by_genre_id is too high. [8/6]
Open

      def self.find_resource_by_genre_id(genre_id)
        case genre_id
        when /^001/ then RWS::Books::Book
        when /^002/ then RWS::Books::CD
        when /^003/ then RWS::Books::DVD

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Assignment Branch Condition size for order is too high. [17.03/15]
Open

    def order(options)
      new_params = params.dup
      if options.is_a? Hash
        key, sort_order = *options.to_a.last
        key = key.to_s.to_camel

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. [15.94/15]
Open

      def initialize(hash)
        @table = {}
        hash.each do |(key, val)|
          val = self.class.new(val) if val.is_a?(Hash)
          val = val.map { |v| self.class.new(v) } if val.is_a?(Array)

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 get is too high. [15.33/15]
Open

    def get(params)
      params = RakutenWebService.configuration.generate_parameters(params)
      response = request(url.path, params)
      body = JSON.parse(response.body)

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

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

module RakutenWebService
  module Books
    class Magazine < Books::Resource
      endpoint 'https://app.rakuten.co.jp/services/api/BooksMagazine/Search/20170404'

Severity: Minor
Found in lib/rakuten_web_service/books/magazine.rb and 1 other location - About 35 mins to fix
lib/rakuten_web_service/books/cd.rb on lines 5..23

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

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 RakutenWebService
  module Books
    class CD < Books::Resource
      endpoint 'https://app.rakuten.co.jp/services/api/BooksCD/Search/20170404'

Severity: Minor
Found in lib/rakuten_web_service/books/cd.rb and 1 other location - About 35 mins to fix
lib/rakuten_web_service/books/magazine.rb on lines 5..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 36.

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

module RakutenWebService
  module Books
    class Game < Books::Resource
      endpoint 'https://app.rakuten.co.jp/services/api/BooksGame/Search/20170404'

Severity: Major
Found in lib/rakuten_web_service/books/game.rb and 3 other locations - About 35 mins to fix
lib/rakuten_web_service/books/dvd.rb on lines 5..23
lib/rakuten_web_service/books/foreign_book.rb on lines 5..22
lib/rakuten_web_service/books/software.rb on lines 5..23

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

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

module RakutenWebService
  module Books
    class Software < Books::Resource
      endpoint 'https://app.rakuten.co.jp/services/api/BooksSoftware/Search/20170404'

Severity: Major
Found in lib/rakuten_web_service/books/software.rb and 3 other locations - About 35 mins to fix
lib/rakuten_web_service/books/dvd.rb on lines 5..23
lib/rakuten_web_service/books/foreign_book.rb on lines 5..22
lib/rakuten_web_service/books/game.rb on lines 5..23

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

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

module RakutenWebService
  module Books
    class ForeignBook < Books::Resource
      endpoint 'https://app.rakuten.co.jp/services/api/BooksForeignBook/Search/20170404'

Severity: Major
Found in lib/rakuten_web_service/books/foreign_book.rb and 3 other locations - About 35 mins to fix
lib/rakuten_web_service/books/dvd.rb on lines 5..23
lib/rakuten_web_service/books/game.rb on lines 5..23
lib/rakuten_web_service/books/software.rb on lines 5..23

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

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

module RakutenWebService
  module Books
    class DVD < Books::Resource
      endpoint 'https://app.rakuten.co.jp/services/api/BooksDVD/Search/20170404'

Severity: Major
Found in lib/rakuten_web_service/books/dvd.rb and 3 other locations - About 35 mins to fix
lib/rakuten_web_service/books/foreign_book.rb on lines 5..22
lib/rakuten_web_service/books/game.rb on lines 5..23
lib/rakuten_web_service/books/software.rb on lines 5..23

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

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

        def initialize(data, parent=nil)
          @parent = parent
          class_data = data
          @params, @children = *(case class_data
                              when Array
Severity: Minor
Found in lib/rakuten_web_service/travel/area_class.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

Replace class var @@repository with a class instance var.
Open

            @@repository ||= Hash.new { |h, k| h[k] = {} }

This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.

Line is too long. [86/80]
Open

      path = "#{path}?#{params.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')}"
Severity: Minor
Found in lib/rakuten_web_service/client.rb by rubocop

Line is too long. [93/80]
Open

      @params['children'] ||= self.class.search(self.class.genre_id_key => id).first.children
Severity: Minor
Found in lib/rakuten_web_service/genre.rb by rubocop

Line is too long. [115/80]
Open

    warn 'Warning: RakutenWebService.configuration is deprecated. Use RakutenWebService.configure.' if block_given?

Align the parameters of a method call if they span more than one line.
Open

      :recipeIndication, :recipeCost,
Severity: Minor
Found in lib/rakuten_web_service/recipe.rb by rubocop

Here we check if the parameters on a multi-line method call or definition are aligned.

Example: EnforcedStyle: withfirstparameter (default)

# good

foo :bar,
    :baz

# bad

foo :bar,
  :baz

Example: EnforcedStyle: withfixedindentation

# good

foo :bar,
  :baz

# bad

foo :bar,
    :baz
Severity
Category
Status
Source
Language