datacite/lupo

View on GitHub
app/models/provider.rb

Summary

Maintainability
F
3 days
Test Coverage
F
55%

File provider.rb has 812 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "countries"

class Provider < ApplicationRecord
  audited except: %i[
    globus_uuid
Severity: Major
Found in app/models/provider.rb - About 1 day to fix

    Class Provider has 64 methods (exceeds 20 allowed). Consider refactoring.
    Wontfix

    class Provider < ApplicationRecord
      audited except: %i[
        globus_uuid
        system_email
        group_email
    Severity: Major
    Found in app/models/provider.rb - About 1 day to fix

      Method as_indexed_json has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def as_indexed_json(options = {})
          {
            "id" => uid,
            "uid" => uid,
            "name" => name,
      Severity: Major
      Found in app/models/provider.rb - About 2 hrs to fix

        Method csv has 61 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def csv
            provider = {
              name: name,
              provider_id: symbol,
              consortium_id: consortium.present? ? consortium.symbol : "",
        Severity: Major
        Found in app/models/provider.rb - About 2 hrs to fix

          Method set_defaults has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def set_defaults
                self.symbol = symbol.upcase if symbol.present?
                self.is_active = is_active ? "\x01" : "\x00"
                self.version = version.present? ? version + 1 : 0
                self.role_name = "ROLE_ALLOCATOR" if role_name.blank?
          Severity: Minor
          Found in app/models/provider.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 query_aggregations has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.query_aggregations
              {
                years: {
                  date_histogram: {
                    field: "created",
          Severity: Minor
          Found in app/models/provider.rb - About 1 hr to fix

            Method to_jsonapi has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def to_jsonapi
                attributes = {
                  "symbol" => symbol,
                  "salesforce_id" => salesforce_id,
                  "consortium_salesforce_id" => consortium_salesforce_id,
            Severity: Minor
            Found in app/models/provider.rb - About 1 hr to fix

              Method as_indexed_json has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                def as_indexed_json(options = {})
                  {
                    "id" => uid,
                    "uid" => uid,
                    "name" => name,
              Severity: Minor
              Found in app/models/provider.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 to_jsonapi has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def to_jsonapi
                  attributes = {
                    "symbol" => symbol,
                    "salesforce_id" => salesforce_id,
                    "consortium_salesforce_id" => consortium_salesforce_id,
              Severity: Minor
              Found in app/models/provider.rb - About 25 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 3 locations. Consider refactoring.
              Open

                    indexes :billing_information,
                            type: :object,
                            properties: {
                              postCode: { type: :keyword },
                              state: { type: :text },
              Severity: Minor
              Found in app/models/provider.rb and 2 other locations - About 35 mins to fix
              app/models/client_prefix.rb on lines 42..53
              app/models/provider_prefix.rb on lines 45..56

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

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

                settings index: {
                  analysis: {
                    analyzer: {
                      string_lowercase: {
                        tokenizer: "keyword", filter: %w[lowercase ascii_folding]
              Severity: Minor
              Found in app/models/provider.rb and 2 other locations - About 30 mins to fix
              app/models/client.rb on lines 120..136
              app/models/contact.rb on lines 44..60

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

                    indexes :voting_contact,
                            type: :object,
                            properties: {
                              uid: { type: :keyword },
                              email: { type: :text },
              Severity: Major
              Found in app/models/provider.rb and 6 other locations - About 20 mins to fix
              app/models/provider.rb on lines 285..294
              app/models/provider.rb on lines 294..303
              app/models/provider.rb on lines 303..312
              app/models/provider.rb on lines 312..321
              app/models/provider.rb on lines 321..330
              app/models/provider.rb on lines 330..339

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

                    indexes :service_contact,
                            type: :object,
                            properties: {
                              uid: { type: :keyword },
                              email: { type: :text },
              Severity: Major
              Found in app/models/provider.rb and 6 other locations - About 20 mins to fix
              app/models/provider.rb on lines 285..294
              app/models/provider.rb on lines 294..303
              app/models/provider.rb on lines 303..312
              app/models/provider.rb on lines 312..321
              app/models/provider.rb on lines 330..339
              app/models/provider.rb on lines 339..348

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

                    indexes :secondary_billing_contact,
                            type: :object,
                            properties: {
                              uid: { type: :keyword },
                              email: { type: :text },
              Severity: Major
              Found in app/models/provider.rb and 6 other locations - About 20 mins to fix
              app/models/provider.rb on lines 285..294
              app/models/provider.rb on lines 294..303
              app/models/provider.rb on lines 303..312
              app/models/provider.rb on lines 321..330
              app/models/provider.rb on lines 330..339
              app/models/provider.rb on lines 339..348

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

                    indexes :secondary_service_contact,
                            type: :object,
                            properties: {
                              uid: { type: :keyword },
                              email: { type: :text },
              Severity: Major
              Found in app/models/provider.rb and 6 other locations - About 20 mins to fix
              app/models/provider.rb on lines 285..294
              app/models/provider.rb on lines 294..303
              app/models/provider.rb on lines 303..312
              app/models/provider.rb on lines 312..321
              app/models/provider.rb on lines 321..330
              app/models/provider.rb on lines 339..348

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

                    indexes :technical_contact,
                            type: :object,
                            properties: {
                              uid: { type: :keyword },
                              email: { type: :text },
              Severity: Major
              Found in app/models/provider.rb and 6 other locations - About 20 mins to fix
              app/models/provider.rb on lines 294..303
              app/models/provider.rb on lines 303..312
              app/models/provider.rb on lines 312..321
              app/models/provider.rb on lines 321..330
              app/models/provider.rb on lines 330..339
              app/models/provider.rb on lines 339..348

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

                    indexes :secondary_technical_contact,
                            type: :object,
                            properties: {
                              uid: { type: :keyword },
                              email: { type: :text },
              Severity: Major
              Found in app/models/provider.rb and 6 other locations - About 20 mins to fix
              app/models/provider.rb on lines 285..294
              app/models/provider.rb on lines 303..312
              app/models/provider.rb on lines 312..321
              app/models/provider.rb on lines 321..330
              app/models/provider.rb on lines 330..339
              app/models/provider.rb on lines 339..348

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

                    indexes :billing_contact,
                            type: :object,
                            properties: {
                              uid: { type: :keyword },
                              email: { type: :text },
              Severity: Major
              Found in app/models/provider.rb and 6 other locations - About 20 mins to fix
              app/models/provider.rb on lines 285..294
              app/models/provider.rb on lines 294..303
              app/models/provider.rb on lines 312..321
              app/models/provider.rb on lines 321..330
              app/models/provider.rb on lines 330..339
              app/models/provider.rb on lines 339..348

              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

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

                def cumulative_years
                  if deleted_at && deleted_at.year > created_at.year
                    (created_at.year...deleted_at.year).to_a
                  elsif deleted_at
                    []
              Severity: Minor
              Found in app/models/provider.rb and 1 other location - About 15 mins to fix
              app/models/client.rb on lines 644..651

              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

              There are no issues that match your filters.

              Category
              Status