neo4jrb/neo4j

View on GitHub
lib/active_graph/railtie.rb

Summary

Maintainability
A
0 mins
Test Coverage

Assignment Branch Condition size for setup! is too high. [19.54/18] (http://c2.com/cgi/wiki?AbcMetric)
Open

    def setup!(config = empty_config)
      config = final_driver_config!(config)
      scheme = config.delete(:scheme) || 'bolt'
      host = config.delete(:host) || 'localhost'
      port = config.delete(:port) || 7687
Severity: Minor
Found in lib/active_graph/railtie.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

Cyclomatic complexity for setup! is too high. [7/6]
Open

    def setup!(config = empty_config)
      config = final_driver_config!(config)
      scheme = config.delete(:scheme) || 'bolt'
      host = config.delete(:host) || 'localhost'
      port = config.delete(:port) || 7687
Severity: Minor
Found in lib/active_graph/railtie.rb by rubocop

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.

Missing magic comment # frozen_string_literal: true.
Open

require 'active_support/notifications'
Severity: Minor
Found in lib/active_graph/railtie.rb by rubocop

This cop is designed to help upgrade to Ruby 3.0. It will add the comment # frozen_string_literal: true to the top of files to enable frozen string literals. Frozen string literals may be default in Ruby 3.0. The comment will be added below a shebang and encoding comment. The frozen string literal comment is only valid in Ruby 2.3+.

Example: EnforcedStyle: when_needed (default)

# The `when_needed` style will add the frozen string literal comment
# to files only when the `TargetRubyVersion` is set to 2.3+.
# bad
module Foo
  # ...
end

# good
# frozen_string_literal: true

module Foo
  # ...
end

Example: EnforcedStyle: always

# The `always` style will always add the frozen string literal comment
# to a file, regardless of the Ruby version or if `freeze` or `<

Example: EnforcedStyle: never

# The `never` will enforce that the frozen string literal comment does
# not exist in a file.
# bad
# frozen_string_literal: true

module Baz
  # ...
end

# good
module Baz
  # ...
end

Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||. (https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier)
Open

      if ActiveGraph::Config.fail_on_pending_migrations
Severity: Minor
Found in lib/active_graph/railtie.rb by rubocop

Checks for if and unless statements that would fit on one line if written as a modifier if/unless. The maximum line length is configured in the Metrics/LineLength cop.

Example:

# bad
if condition
  do_stuff(bar)
end

unless qux.empty?
  Foo.do_something
end

# good
do_stuff(bar) if condition
Foo.do_something unless qux.empty?

Space inside parentheses detected. (https://github.com/bbatsov/ruby-style-guide#spaces-braces)
Open

      url = config.delete(:url) || URI::Generic.build( scheme: scheme, host: host, port: port ).to_s
Severity: Minor
Found in lib/active_graph/railtie.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Space inside parentheses detected. (https://github.com/bbatsov/ruby-style-guide#spaces-braces)
Open

      url = config.delete(:url) || URI::Generic.build( scheme: scheme, host: host, port: port ).to_s
Severity: Minor
Found in lib/active_graph/railtie.rb by rubocop

Checks for spaces inside ordinary round parentheses.

Example:

# bad
f( 3)
g = (a + 3 )

# good
f(3)
g = (a + 3)

Space inside { detected. (https://github.com/bbatsov/ruby-style-guide#spaces-operators)
Open

      { url: ENV['NEO4J_URL'] }.compact.merge(config[:driver]).merge(yaml_config_data)
Severity: Minor
Found in lib/active_graph/railtie.rb by rubocop

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

Example: EnforcedStyle: space

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

# bad
h = {a: 1, b: 2}

# good
h = { a: 1, b: 2 }

Example: EnforcedStyle: no_space

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

# bad
h = { a: 1, b: 2 }

# good
h = {a: 1, b: 2}

Example: EnforcedStyle: compact

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

# bad
h = { a: { b: 2 } }

# good
h = { a: { b: 2 }}

Space inside } detected. (https://github.com/bbatsov/ruby-style-guide#spaces-operators)
Open

      { url: ENV['NEO4J_URL'] }.compact.merge(config[:driver]).merge(yaml_config_data)
Severity: Minor
Found in lib/active_graph/railtie.rb by rubocop

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

Example: EnforcedStyle: space

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

# bad
h = {a: 1, b: 2}

# good
h = { a: 1, b: 2 }

Example: EnforcedStyle: no_space

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

# bad
h = { a: 1, b: 2 }

# good
h = {a: 1, b: 2}

Example: EnforcedStyle: compact

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

# bad
h = { a: { b: 2 } }

# good
h = { a: { b: 2 }}

Use safe navigation (&.) instead of checking if an object exists before calling the method.
Open

      app.config.neo4j.each { |k, v| neo4j_config[k] = v } if app.config.neo4j
Severity: Minor
Found in lib/active_graph/railtie.rb by rubocop

This cop transforms usages of a method call safeguarded by a non nil check for the variable whose method is being called to safe navigation (&.).

Configuration option: ConvertCodeThatCanStartToReturnNil The default for this is false. When configured to true, this will check for code in the format !foo.nil? && foo.bar. As it is written, the return of this code is limited to false and whatever the return of the method is. If this is converted to safe navigation, foo&.bar can start returning nil as well as what the method returns.

Example:

# bad
foo.bar if foo
foo.bar(param1, param2) if foo
foo.bar { |e| e.something } if foo
foo.bar(param) { |e| e.something } if foo

foo.bar if !foo.nil?
foo.bar unless !foo
foo.bar unless foo.nil?

foo && foo.bar
foo && foo.bar(param1, param2)
foo && foo.bar { |e| e.something }
foo && foo.bar(param) { |e| e.something }

# good
foo&.bar
foo&.bar(param1, param2)
foo&.bar { |e| e.something }
foo&.bar(param) { |e| e.something }

foo.nil? || foo.bar
!foo || foo.bar

# Methods that `nil` will `respond_to?` should not be converted to
# use safe navigation
foo.to_i if foo

Prefer using YAML.safe_load over YAML.load. (https://ruby-doc.org/stdlib-2.3.3/libdoc/yaml/rdoc/YAML.html#module-YAML-label-Security)
Open

        yaml_path ? YAML.load(ERB.new(yaml_path.read).result)[Rails.env].transform_keys!(&:to_sym) : {}
Severity: Minor
Found in lib/active_graph/railtie.rb by rubocop

This cop checks for the use of YAML class methods which have potential security issues leading to remote code execution when loading from an untrusted source.

Example:

# bad
YAML.load("--- foo")

# good
YAML.safe_load("--- foo")
YAML.dump("foo")

There are no issues that match your filters.

Category
Status