cerebris/jsonapi-resources

View on GitHub

Showing 51 of 156 total issues

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

    class InvalidFieldFormat < Error
      def errors
        [create_error_object(code: JSONAPI::INVALID_FIELD_FORMAT,
                             status: :bad_request,
                             title: I18n.translate('jsonapi-resources.exceptions.invalid_field_format.title',
Severity: Major
Found in lib/jsonapi/exceptions.rb and 7 other locations - About 15 mins to fix
lib/jsonapi/exceptions.rb on lines 162..169
lib/jsonapi/exceptions.rb on lines 173..180
lib/jsonapi/exceptions.rb on lines 272..279
lib/jsonapi/exceptions.rb on lines 283..290
lib/jsonapi/exceptions.rb on lines 447..454
lib/jsonapi/exceptions.rb on lines 532..539
lib/jsonapi/exceptions.rb on lines 543..550

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

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

    class InvalidPageObject < Error
      def errors
        [create_error_object(code: JSONAPI::INVALID_PAGE_OBJECT,
                             status: :bad_request,
                             title: I18n.translate('jsonapi-resources.exceptions.invalid_page_object.title',
Severity: Major
Found in lib/jsonapi/exceptions.rb and 7 other locations - About 15 mins to fix
lib/jsonapi/exceptions.rb on lines 162..169
lib/jsonapi/exceptions.rb on lines 173..180
lib/jsonapi/exceptions.rb on lines 261..268
lib/jsonapi/exceptions.rb on lines 272..279
lib/jsonapi/exceptions.rb on lines 283..290
lib/jsonapi/exceptions.rb on lines 447..454
lib/jsonapi/exceptions.rb on lines 532..539

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

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

    class MissingKey < Error
      def errors
        [create_error_object(code: JSONAPI::KEY_ORDER_MISMATCH,
                             status: :bad_request,
                             title: I18n.translate('jsonapi-resources.exceptions.missing_key.title',
Severity: Major
Found in lib/jsonapi/exceptions.rb and 7 other locations - About 15 mins to fix
lib/jsonapi/exceptions.rb on lines 162..169
lib/jsonapi/exceptions.rb on lines 173..180
lib/jsonapi/exceptions.rb on lines 261..268
lib/jsonapi/exceptions.rb on lines 272..279
lib/jsonapi/exceptions.rb on lines 283..290
lib/jsonapi/exceptions.rb on lines 532..539
lib/jsonapi/exceptions.rb on lines 543..550

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

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

    class SaveFailed < Error
      def errors
        [create_error_object(code: JSONAPI::SAVE_FAILED,
                             status: :unprocessable_entity,
                             title: I18n.translate('jsonapi-resources.exceptions.save_failed.title',
Severity: Major
Found in lib/jsonapi/exceptions.rb and 7 other locations - About 15 mins to fix
lib/jsonapi/exceptions.rb on lines 162..169
lib/jsonapi/exceptions.rb on lines 173..180
lib/jsonapi/exceptions.rb on lines 261..268
lib/jsonapi/exceptions.rb on lines 272..279
lib/jsonapi/exceptions.rb on lines 283..290
lib/jsonapi/exceptions.rb on lines 447..454
lib/jsonapi/exceptions.rb on lines 543..550

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

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

    class InvalidLinksObject < Error
      def errors
        [create_error_object(code: JSONAPI::INVALID_LINKS_OBJECT,
                             status: :bad_request,
                             title: I18n.translate('jsonapi-resources.exceptions.invalid_links_object.title',
Severity: Major
Found in lib/jsonapi/exceptions.rb and 7 other locations - About 15 mins to fix
lib/jsonapi/exceptions.rb on lines 162..169
lib/jsonapi/exceptions.rb on lines 173..180
lib/jsonapi/exceptions.rb on lines 261..268
lib/jsonapi/exceptions.rb on lines 272..279
lib/jsonapi/exceptions.rb on lines 447..454
lib/jsonapi/exceptions.rb on lines 532..539
lib/jsonapi/exceptions.rb on lines 543..550

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

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

    class ToManySetReplacementForbidden < Error
      def errors
        [create_error_object(code: JSONAPI::FORBIDDEN,
                             status: :forbidden,
                             title: I18n.translate('jsonapi-resources.exceptions.to_many_set_replacement_forbidden.title',
Severity: Major
Found in lib/jsonapi/exceptions.rb and 7 other locations - About 15 mins to fix
lib/jsonapi/exceptions.rb on lines 162..169
lib/jsonapi/exceptions.rb on lines 261..268
lib/jsonapi/exceptions.rb on lines 272..279
lib/jsonapi/exceptions.rb on lines 283..290
lib/jsonapi/exceptions.rb on lines 447..454
lib/jsonapi/exceptions.rb on lines 532..539
lib/jsonapi/exceptions.rb on lines 543..550

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

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

    class InvalidRequestFormat < Error
      def errors
        [create_error_object(code: JSONAPI::BAD_REQUEST,
                             status: :bad_request,
                             title: I18n.translate('jsonapi-resources.exceptions.invalid_request_format.title',
Severity: Major
Found in lib/jsonapi/exceptions.rb and 7 other locations - About 15 mins to fix
lib/jsonapi/exceptions.rb on lines 173..180
lib/jsonapi/exceptions.rb on lines 261..268
lib/jsonapi/exceptions.rb on lines 272..279
lib/jsonapi/exceptions.rb on lines 283..290
lib/jsonapi/exceptions.rb on lines 447..454
lib/jsonapi/exceptions.rb on lines 532..539
lib/jsonapi/exceptions.rb on lines 543..550

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

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

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

          if methods.include?(:show)
            match "relationships/#{formatted_relationship_name}", controller: options[:controller],
                  action: 'show_relationship', relationship: link_type.to_s, via: [:get],
                  as: "relationships/#{link_type}"
          end
Severity: Minor
Found in lib/jsonapi/routing_ext.rb and 1 other location - About 15 mins to fix
lib/jsonapi/routing_ext.rb on lines 198..202

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

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

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

          if methods.include?(:show)
            match "relationships/#{formatted_relationship_name}", controller: options[:controller],
                  action: 'show_relationship', relationship: link_type.to_s, via: [:get],
                  as: "relationships/#{link_type}"
          end
Severity: Minor
Found in lib/jsonapi/routing_ext.rb and 1 other location - About 15 mins to fix
lib/jsonapi/routing_ext.rb on lines 169..173

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

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

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

              klass.reflect_on_all_associations(:has_many).select{|r| r.options[:as] }.each do |reflection|
                (hash[reflection.options[:as]] ||= []) << klass.name.downcase
Severity: Minor
Found in lib/jsonapi/basic_resource.rb and 1 other location - About 15 mins to fix
lib/jsonapi/relationship.rb on lines 67..68

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

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

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

            klass.reflect_on_all_associations(:has_many).select{|r| r.options[:as] }.each do |reflection|
              (hash[reflection.options[:as]] ||= []) << klass.name.downcase
Severity: Minor
Found in lib/jsonapi/relationship.rb and 1 other location - About 15 mins to fix
lib/jsonapi/basic_resource.rb on lines 930..931

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

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

Severity
Category
Status
Source
Language