wrstudios/frodata

View on GitHub
lib/frodata/entity_container.rb

Summary

Maintainability
A
0 mins
Test Coverage

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

    def [](entity_set_name)
      xpath_query = "//EntitySet[@Name='#{entity_set_name}']"
      entity_set_node = metadata.xpath(xpath_query).first
      raise ArgumentError, "Unknown Entity Set: #{entity_set_name}" if entity_set_node.nil?
      entity_type = entity_set_node.attributes['EntityType'].value
Severity: Minor
Found in lib/frodata/entity_container.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.

FrOData::EntityContainer has no descriptive comment
Open

  class EntityContainer
Severity: Minor
Found in lib/frodata/entity_container.rb by reek

Classes and modules are the units of reuse and release. It is therefore considered good practice to annotate every class and module with a brief comment outlining its responsibilities.

Example

Given

class Dummy
  # Do things...
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [1]:Dummy has no descriptive comment (IrresponsibleModule)

Fixing this is simple - just an explaining comment:

# The Dummy class is responsible for ...
class Dummy
  # Do things...
end

FrOData::EntityContainer#entity_sets calls 'entity.attributes' 2 times
Open

          entity.attributes['Name'].value,
          entity.attributes['EntityType'].value
Severity: Minor
Found in lib/frodata/entity_container.rb by reek

Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

Reek implements a check for Duplicate Method Call.

Example

Here's a very much simplified and contrived example. The following method will report a warning:

def double_thing()
  @other.thing + @other.thing
end

One quick approach to silence Reek would be to refactor the code thus:

def double_thing()
  thing = @other.thing
  thing + thing
end

A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

class Other
  def double_thing()
    thing + thing
  end
end

The approach you take will depend on balancing other factors in your code.

FrOData::EntityContainer#[] performs a nil-check
Open

      raise ArgumentError, "Unknown Entity Set: #{entity_set_name}" if entity_set_node.nil?
Severity: Minor
Found in lib/frodata/entity_container.rb by reek

A NilCheck is a type check. Failures of NilCheck violate the "tell, don't ask" principle.

Additionally, type checks often mask bigger problems in your source code like not using OOP and / or polymorphism when you should.

Example

Given

class Klass
  def nil_checker(argument)
    if argument.nil?
      puts "argument isn't nil!"
    end
  end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [3]:Klass#nil_checker performs a nil-check. (NilCheck)

Annotation keywords like TODO should be all upper case, followed by a colon, and a space, then a note describing the problem.
Open

      # TODO return singletons exposed by this EntityContainer
Severity: Minor
Found in lib/frodata/entity_container.rb by rubocop

This cop checks that comment annotation keywords are written according to guidelines.

Example:

# bad
# TODO make better

# good
# TODO: make better

# bad
# TODO:make better

# good
# TODO: make better

# bad
# fixme: does not work

# good
# FIXME: does not work

# bad
# Optimize does not work

# good
# OPTIMIZE: does not work

Annotation keywords like TODO should be all upper case, followed by a colon, and a space, then a note describing the problem.
Open

      # TODO return function imports exposed by this EntityContainer
Severity: Minor
Found in lib/frodata/entity_container.rb by rubocop

This cop checks that comment annotation keywords are written according to guidelines.

Example:

# bad
# TODO make better

# good
# TODO: make better

# bad
# TODO:make better

# good
# TODO: make better

# bad
# fixme: does not work

# good
# FIXME: does not work

# bad
# Optimize does not work

# good
# OPTIMIZE: does not work

Annotation keywords like TODO should be all upper case, followed by a colon, and a space, then a note describing the problem.
Open

      # TODO return action imports exposed by this EntityContainer
Severity: Minor
Found in lib/frodata/entity_container.rb by rubocop

This cop checks that comment annotation keywords are written according to guidelines.

Example:

# bad
# TODO make better

# good
# TODO: make better

# bad
# TODO:make better

# good
# TODO: make better

# bad
# fixme: does not work

# good
# FIXME: does not work

# bad
# Optimize does not work

# good
# OPTIMIZE: does not work

Line is too long. [91/80]
Open

      raise ArgumentError, "Unknown Entity Set: #{entity_set_name}" if entity_set_node.nil?
Severity: Minor
Found in lib/frodata/entity_container.rb by rubocop

There are no issues that match your filters.

Category
Status