distil/jserializer

View on GitHub
test/association_test.rb

Summary

Maintainability
A
2 hrs
Test Coverage

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

      it 'replaces _ids with embed_key option in has_many statement' do
        blog = build_a_blog(total_posts: 4, comments_per_post: 5)
        serializer = BlogEmbedKeyHasManySerializer.new(blog)
        result = serializer.serializable_hash
        assert_equal([:post_ids, :account], result.keys)
Severity: Minor
Found in test/association_test.rb and 1 other location - About 30 mins to fix
test/association_test.rb on lines 278..283

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

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

      it 'renames attribute key with embed ids' do
        blog = build_a_blog(total_posts: 4, comments_per_post: 5)
        serializer = BlogEmbedKeyWithKeySerializer.new(blog)
        result = serializer.serializable_hash
        assert_equal([:article_ids, :account], result.keys)
Severity: Minor
Found in test/association_test.rb and 1 other location - About 30 mins to fix
test/association_test.rb on lines 262..267

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

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

      result[:post_comments].each.with_index(1) do |comment, i|
        assert_equal([:id, :body, :who], comment.keys)
        assert_equal([i, "This is comment ##{i}", "User #{i}"], comment.values)
Severity: Minor
Found in test/association_test.rb and 2 other locations - About 20 mins to fix
test/association_test.rb on lines 146..148
test/association_test.rb on lines 210..212

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

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

      result[:comments].each.with_index(1) do |comment, i|
        assert_equal([:id, :body, :who], comment.keys)
        assert_equal([i, "This is comment ##{i}", "User #{i}"], comment.values)
Severity: Minor
Found in test/association_test.rb and 2 other locations - About 20 mins to fix
test/association_test.rb on lines 146..148
test/association_test.rb on lines 192..194

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

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

      result[:comments].each.with_index(1) do |comment, i|
        assert_equal([:id, :body, :who], comment.keys)
        assert_equal([i, "This is comment ##{i}", "User #{i}"], comment.values)
Severity: Minor
Found in test/association_test.rb and 2 other locations - About 20 mins to fix
test/association_test.rb on lines 192..194
test/association_test.rb on lines 210..212

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

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

Argument post was shadowed by a local variable before it was used.
Open

        post = Post.new(i, "Post #{i}", "Text #{i}")
Severity: Minor
Found in test/association_test.rb by rubocop

This cop checks for shadowed arguments.

This cop has IgnoreImplicitReferences configuration option. It means argument shadowing is used in order to pass parameters to zero arity super when IgnoreImplicitReferences is true.

Example:

# bad
do_something do |foo|
  foo = 42
  puts foo
end

def do_something(foo)
  foo = 42
  puts foo
end

# good
do_something do |foo|
  foo = foo + 42
  puts foo
end

def do_something(foo)
  foo = foo + 42
  puts foo
end

def do_something(foo)
  puts foo
end

Example: IgnoreImplicitReferences: false (default)

# bad
def do_something(foo)
  foo = 42
  super
end

def do_something(foo)
  foo = super
  bar
end

Example: IgnoreImplicitReferences: true

# good
def do_something(foo)
  foo = 42
  super
end

def do_something(foo)
  foo = super
  bar
end

There are no issues that match your filters.

Category
Status