gregbeech/xenon

View on GitHub

Showing 51 of 51 total issues

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

    def self.parse(s)
      tree = Parsers::MediaType.new.parse(s)
      Parsers::MediaTypeTransform.new.apply(tree)
    rescue Parslet::ParseFailed
      raise Xenon::ParseError.new("Invalid media type (#{s}).")
Severity: Minor
Found in xenon-http/lib/xenon/media_type.rb and 2 other locations - About 20 mins to fix
xenon-http/lib/xenon/headers/authorization.rb on lines 16..20
xenon-http/lib/xenon/media_type.rb on lines 123..127

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

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

      def self.parse(s)
        tree = Parsers::AuthorizationHeader.new.parse(s)
        Parsers::AuthorizationHeaderTransform.new.apply(tree)
      rescue Parslet::ParseFailed
        raise Xenon::ParseError.new("Invalid Authorization header (#{s}).")
Severity: Minor
Found in xenon-http/lib/xenon/headers/authorization.rb and 2 other locations - About 20 mins to fix
xenon-http/lib/xenon/media_type.rb on lines 28..32
xenon-http/lib/xenon/media_type.rb on lines 123..127

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

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

    def self.parse(s)
      tree = Parsers::MediaRange.new.parse(s)
      Parsers::MediaTypeTransform.new.apply(tree)
    rescue Parslet::ParseFailed
      raise Xenon::ParseError.new("Invalid media range (#{s})")
Severity: Minor
Found in xenon-http/lib/xenon/media_type.rb and 2 other locations - About 20 mins to fix
xenon-http/lib/xenon/headers/authorization.rb on lines 16..20
xenon-http/lib/xenon/media_type.rb on lines 28..32

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

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

Ambiguous splat operator. Parenthesize the method arguments if it's surely a splat operator, or add a whitespace to the right of the * if it should be a multiplication.
Open

            yield *captures

This cop checks for ambiguous operators in the first argument of a method invocation without parentheses.

Example:

# bad

# The `*` is interpreted as a splat operator but it could possibly be
# a `*` method invocation (i.e. `do_something.*(some_array)`).
do_something *some_array

Example:

# good

# With parentheses, there's no ambiguity.
do_something(*some_array)

unexpected token tRPAREN
Open

    def unmarshal(body, as:)

unexpected token kNIL
Open

    def initialize(scheme, token: nil, params: {})
Severity: Minor
Found in xenon-http/lib/xenon/auth.rb by rubymotion

Shadowing outer local variable - media_range.
Open

          media_range = media_ranges.find { |media_range| marshaller.marshal?(media_range) }
Severity: Minor
Found in xenon-routing/lib/xenon/api.rb by rubocop

This cop looks for use of the same name as outer local variables for block arguments or block local variables. This is a mimic of the warning "shadowing outer local variable - foo" from ruby -cw.

Example:

# bad

def some_method
  foo = 1

  2.times do |foo| # shadowing outer `foo`
    do_something(foo)
  end
end

Example:

# good

def some_method
  foo = 1

  2.times do |bar|
    do_something(bar)
  end
end

class definition in method body
Open

  class JsonMarshaller

unexpected token error
Open

      %i(delete head options patch post put).each do |method|

unexpected token kNIL
Open

      def body(as: nil)

class definition in method body
Open

  class BasicAuth
Severity: Minor
Found in xenon-http/lib/xenon/auth.rb by rubymotion

class definition in method body
Open

  class XmlMarshaller

unexpected token error
Open

  %i(=~ ===).each do |name|

Ambiguous splat operator. Parenthesize the method arguments if it's surely a splat operator, or add a whitespace to the right of the * if it should be a multiplication.
Open

            yield *values

This cop checks for ambiguous operators in the first argument of a method invocation without parentheses.

Example:

# bad

# The `*` is interpreted as a splat operator but it could possibly be
# a `*` method invocation (i.e. `do_something.*(some_array)`).
do_something *some_array

Example:

# good

# With parentheses, there's no ambiguity.
do_something(*some_array)

Ambiguous splat operator. Parenthesize the method arguments if it's surely a splat operator, or add a whitespace to the right of the * if it should be a multiplication.
Open

              yield *match.captures

This cop checks for ambiguous operators in the first argument of a method invocation without parentheses.

Example:

# bad

# The `*` is interpreted as a splat operator but it could possibly be
# a `*` method invocation (i.e. `do_something.*(some_array)`).
do_something *some_array

Example:

# good

# With parentheses, there's no ambiguity.
do_something(*some_array)

unexpected token kFALSE
Open

    def initialize(tag, weak: false)
Severity: Minor
Found in xenon-http/lib/xenon/etag.rb by rubymotion

Useless assignment to variable - value.
Open

              value = hash[param_def]

This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

assigned but unused variable - foo

Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

Example:

# bad

def some_method
  some_var = 1
  do_something
end

Example:

# good

def some_method
  some_var = 1
  do_something(some_var)
end

class definition in method body
Open

  class ETag
Severity: Minor
Found in xenon-http/lib/xenon/etag.rb by rubymotion

module definition in method body
Open

    module MarshallingDirectives

module definition in method body
Open

module Xenon
Severity: Minor
Found in xenon-http/lib/xenon/etag.rb by rubymotion
Severity
Category
Status
Source
Language