datacite/lupo

View on GitHub
app/graphql/types/doi_item.rb

Summary

Maintainability
F
1 wk
Test Coverage

File doi_item.rb has 861 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module DoiItem
  include BaseInterface
  include Bolognese::MetadataUtils

  REGISTRATION_AGENCIES = {
Severity: Major
Found in app/graphql/types/doi_item.rb - About 2 days to fix

    Method schema_org has 97 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def schema_org
        hsh = {
          "@context" => "http://schema.org",
          "@type" => object.types.present? ? object.types["schemaOrg"] : nil,
          "@id" => normalize_doi(object.doi),
    Severity: Major
    Found in app/graphql/types/doi_item.rb - About 3 hrs to fix

      Method citeproc_hsh has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def citeproc_hsh
          page =
            if object.container.to_h["firstPage"].present?
              [object.container["firstPage"], object.container["lastPage"]].compact.
                join("-")
      Severity: Major
      Found in app/graphql/types/doi_item.rb - About 2 hrs to fix

        Method schema_org has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

          def schema_org
            hsh = {
              "@context" => "http://schema.org",
              "@type" => object.types.present? ? object.types["schemaOrg"] : nil,
              "@id" => normalize_doi(object.doi),
        Severity: Minor
        Found in app/graphql/types/doi_item.rb - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method response has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def response(**args)
            # make sure no dois are returnded if there are no :ids
            args[:ids] = "999" if args[:ids].blank?
        
            Doi.gql_query(
        Severity: Minor
        Found in app/graphql/types/doi_item.rb - About 1 hr to fix

          Method bibtex has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def bibtex
              pages =
                if object.container.to_h["firstPage"].present?
                  [object.container["firstPage"], object.container["lastPage"]].compact.
                    join("-")
          Severity: Minor
          Found in app/graphql/types/doi_item.rb - About 1 hr to fix

            Method citeproc_hsh has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def citeproc_hsh
                page =
                  if object.container.to_h["firstPage"].present?
                    [object.container["firstPage"], object.container["lastPage"]].compact.
                      join("-")
            Severity: Minor
            Found in app/graphql/types/doi_item.rb - About 55 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Method reverse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def reverse
                {
                  "citation" =>
                    Array.wrap(object.related_identifiers).select do |ri|
                      ri["relationType"] == "IsReferencedBy"
            Severity: Minor
            Found in app/graphql/types/doi_item.rb - About 35 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

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

              field :part_of,
                    WorkConnectionWithTotalType,
                    null: true,
                    max_page_size: 100,
                    description: "The DOI is a part of this DOI." do
            Severity: Major
            Found in app/graphql/types/doi_item.rb and 6 other locations - About 4 hrs to fix
            app/graphql/types/doi_item.rb on lines 223..253
            app/graphql/types/doi_item.rb on lines 255..285
            app/graphql/types/doi_item.rb on lines 287..317
            app/graphql/types/doi_item.rb on lines 338..366
            app/graphql/types/doi_item.rb on lines 400..428
            app/graphql/types/doi_item.rb on lines 430..460

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

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

              field :other_related,
                   WorkConnectionWithTotalType,
                   null: true,
                   max_page_size: 100,
                   description: "Other works related to this DOI." do
            Severity: Major
            Found in app/graphql/types/doi_item.rb and 6 other locations - About 4 hrs to fix
            app/graphql/types/doi_item.rb on lines 223..253
            app/graphql/types/doi_item.rb on lines 255..285
            app/graphql/types/doi_item.rb on lines 338..366
            app/graphql/types/doi_item.rb on lines 368..398
            app/graphql/types/doi_item.rb on lines 400..428
            app/graphql/types/doi_item.rb on lines 430..460

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

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

              field :versions,
                    WorkConnectionWithTotalType,
                    null: true, max_page_size: 100, description: "Versions of this DOI." do
                argument :query, String, required: false
                argument :ids, [String], required: false
            Severity: Major
            Found in app/graphql/types/doi_item.rb and 6 other locations - About 4 hrs to fix
            app/graphql/types/doi_item.rb on lines 223..253
            app/graphql/types/doi_item.rb on lines 255..285
            app/graphql/types/doi_item.rb on lines 287..317
            app/graphql/types/doi_item.rb on lines 338..366
            app/graphql/types/doi_item.rb on lines 368..398
            app/graphql/types/doi_item.rb on lines 430..460

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

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

              field :version_of,
                    WorkConnectionWithTotalType,
                    null: true,
                    max_page_size: 100,
                    description: "The DOI is a version of this DOI." do
            Severity: Major
            Found in app/graphql/types/doi_item.rb and 6 other locations - About 4 hrs to fix
            app/graphql/types/doi_item.rb on lines 223..253
            app/graphql/types/doi_item.rb on lines 255..285
            app/graphql/types/doi_item.rb on lines 287..317
            app/graphql/types/doi_item.rb on lines 338..366
            app/graphql/types/doi_item.rb on lines 368..398
            app/graphql/types/doi_item.rb on lines 400..428

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

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

              field :references,
                    WorkConnectionWithTotalType,
                    null: true,
                    max_page_size: 100,
                    description: "References for this DOI" do
            Severity: Major
            Found in app/graphql/types/doi_item.rb and 6 other locations - About 4 hrs to fix
            app/graphql/types/doi_item.rb on lines 255..285
            app/graphql/types/doi_item.rb on lines 287..317
            app/graphql/types/doi_item.rb on lines 338..366
            app/graphql/types/doi_item.rb on lines 368..398
            app/graphql/types/doi_item.rb on lines 400..428
            app/graphql/types/doi_item.rb on lines 430..460

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

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

              field :citations,
                    WorkConnectionWithTotalType,
                    null: true,
                    max_page_size: 100,
                    description: "Citations for this DOI." do
            Severity: Major
            Found in app/graphql/types/doi_item.rb and 6 other locations - About 4 hrs to fix
            app/graphql/types/doi_item.rb on lines 223..253
            app/graphql/types/doi_item.rb on lines 287..317
            app/graphql/types/doi_item.rb on lines 338..366
            app/graphql/types/doi_item.rb on lines 368..398
            app/graphql/types/doi_item.rb on lines 400..428
            app/graphql/types/doi_item.rb on lines 430..460

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

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

              field :parts,
                    WorkConnectionWithTotalType,
                    null: true, max_page_size: 100, description: "Parts of this DOI." do
                argument :query, String, required: false
                argument :ids, [String], required: false
            Severity: Major
            Found in app/graphql/types/doi_item.rb and 6 other locations - About 4 hrs to fix
            app/graphql/types/doi_item.rb on lines 223..253
            app/graphql/types/doi_item.rb on lines 255..285
            app/graphql/types/doi_item.rb on lines 287..317
            app/graphql/types/doi_item.rb on lines 368..398
            app/graphql/types/doi_item.rb on lines 400..428
            app/graphql/types/doi_item.rb on lines 430..460

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

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

                  ids: args[:ids],
                  user_id: args[:user_id],
                  client_id: args[:repository_id],
                  provider_id: args[:member_id],
                  resource_type_id: args[:resource_type_id],
            Severity: Major
            Found in app/graphql/types/doi_item.rb and 1 other location - About 3 hrs to fix
            app/graphql/types/repository_type.rb on lines 368..395

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

            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

                    Array.wrap(object.related_identifiers).select do |ri|
                      ri["relationType"] == "IsSupplementTo"
                    end.map do |r|
                      {
                        "@id" => normalize_doi(r["relatedIdentifier"]),
            Severity: Minor
            Found in app/graphql/types/doi_item.rb and 1 other location - About 45 mins to fix
            app/graphql/types/doi_item.rb on lines 725..732

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

            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

                    Array.wrap(object.related_identifiers).select do |ri|
                      ri["relationType"] == "IsReferencedBy"
                    end.map do |r|
                      {
                        "@id" => normalize_doi(r["relatedIdentifier"]),
            Severity: Minor
            Found in app/graphql/types/doi_item.rb and 1 other location - About 45 mins to fix
            app/graphql/types/doi_item.rb on lines 736..743

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

            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

            There are no issues that match your filters.

            Category
            Status