datacite/lupo

View on GitHub
app/models/contact.rb

Summary

Maintainability
F
5 days
Test Coverage
F
33%

File contact.rb has 456 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Contact < ApplicationRecord
  strip_attributes

  # include helper module for Elasticsearch
  include Indexable
Severity: Minor
Found in app/models/contact.rb - About 6 hrs to fix

    Method import_from_providers has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.import_from_providers
        Provider.all.find_each do |provider|
          if provider.voting_contact_email
            contact = Contact.where(email: provider.voting_contact_email).first_or_create
            if contact.update(
    Severity: Minor
    Found in app/models/contact.rb - About 6 hrs 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 import_from_providers has 93 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.import_from_providers
        Provider.all.find_each do |provider|
          if provider.voting_contact_email
            contact = Contact.where(email: provider.voting_contact_email).first_or_create
            if contact.update(
    Severity: Major
    Found in app/models/contact.rb - About 3 hrs to fix

      Method has_provider_role? has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

        def has_provider_role?(role)
          case role
          when "voting"
            provider.voting_contact_email == email ? true : nil
          when "billing"
      Severity: Minor
      Found in app/models/contact.rb - About 3 hrs 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

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

            indexes :provider,
                    type: :object,
                    properties: {
                      id: { type: :keyword },
                      uid: { type: :keyword },
      Severity: Major
      Found in app/models/contact.rb and 1 other location - About 1 day to fix
      app/models/client.rb on lines 216..359

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

      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

        def self.export(query: nil)
          # Loop through all contacts
          i = 0
          page = { size: 1_000, number: 1 }
          response = self.query(query, include_deleted: true, page: page)
      Severity: Major
      Found in app/models/contact.rb and 1 other location - About 2 hrs to fix
      app/models/client.rb on lines 686..711

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

      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

            if provider.technical_contact_email
              contact = Contact.where(email: provider.technical_contact_email).first_or_create
              if contact.update(
                email: provider.technical_contact_email.downcase,
                provider_id: provider.uid,
      Severity: Major
      Found in app/models/contact.rb and 6 other locations - About 1 hr to fix
      app/models/contact.rb on lines 351..361
      app/models/contact.rb on lines 364..374
      app/models/contact.rb on lines 377..387
      app/models/contact.rb on lines 390..400
      app/models/contact.rb on lines 403..413
      app/models/contact.rb on lines 429..439

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

      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

            if provider.billing_contact_email
              contact = Contact.where(email: provider.billing_contact_email).first_or_create
              if contact.update(
                email: provider.billing_contact_email.downcase,
                provider_id: provider.uid,
      Severity: Major
      Found in app/models/contact.rb and 6 other locations - About 1 hr to fix
      app/models/contact.rb on lines 351..361
      app/models/contact.rb on lines 377..387
      app/models/contact.rb on lines 390..400
      app/models/contact.rb on lines 403..413
      app/models/contact.rb on lines 416..426
      app/models/contact.rb on lines 429..439

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

      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

            if provider.secondary_service_contact_email
              contact = Contact.where(email: provider.secondary_service_contact_email).first_or_create
              if contact.update(
                email: provider.secondary_service_contact_email.downcase,
                provider_id: provider.uid,
      Severity: Major
      Found in app/models/contact.rb and 6 other locations - About 1 hr to fix
      app/models/contact.rb on lines 351..361
      app/models/contact.rb on lines 364..374
      app/models/contact.rb on lines 377..387
      app/models/contact.rb on lines 390..400
      app/models/contact.rb on lines 416..426
      app/models/contact.rb on lines 429..439

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

      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

            if provider.secondary_technical_contact_email
              contact = Contact.where(email: provider.secondary_technical_contact_email).first_or_create
              if contact.update(
                email: provider.secondary_technical_contact_email.downcase,
                provider_id: provider.uid,
      Severity: Major
      Found in app/models/contact.rb and 6 other locations - About 1 hr to fix
      app/models/contact.rb on lines 351..361
      app/models/contact.rb on lines 364..374
      app/models/contact.rb on lines 377..387
      app/models/contact.rb on lines 390..400
      app/models/contact.rb on lines 403..413
      app/models/contact.rb on lines 416..426

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

      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

            if provider.secondary_billing_contact_email
              contact = Contact.where(email: provider.secondary_billing_contact_email).first_or_create
              if contact.update(
                email: provider.secondary_billing_contact_email.downcase,
                provider_id: provider.uid,
      Severity: Major
      Found in app/models/contact.rb and 6 other locations - About 1 hr to fix
      app/models/contact.rb on lines 351..361
      app/models/contact.rb on lines 364..374
      app/models/contact.rb on lines 390..400
      app/models/contact.rb on lines 403..413
      app/models/contact.rb on lines 416..426
      app/models/contact.rb on lines 429..439

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

      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

            if provider.service_contact_email
              contact = Contact.where(email: provider.service_contact_email).first_or_create
              if contact.update(
                email: provider.service_contact_email.downcase,
                provider_id: provider.uid,
      Severity: Major
      Found in app/models/contact.rb and 6 other locations - About 1 hr to fix
      app/models/contact.rb on lines 351..361
      app/models/contact.rb on lines 364..374
      app/models/contact.rb on lines 377..387
      app/models/contact.rb on lines 403..413
      app/models/contact.rb on lines 416..426
      app/models/contact.rb on lines 429..439

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

      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

            if provider.voting_contact_email
              contact = Contact.where(email: provider.voting_contact_email).first_or_create
              if contact.update(
                email: provider.voting_contact_email.downcase,
                provider_id: provider.uid,
      Severity: Major
      Found in app/models/contact.rb and 6 other locations - About 1 hr to fix
      app/models/contact.rb on lines 364..374
      app/models/contact.rb on lines 377..387
      app/models/contact.rb on lines 390..400
      app/models/contact.rb on lines 403..413
      app/models/contact.rb on lines 416..426
      app/models/contact.rb on lines 429..439

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

      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/contact.rb and 2 other locations - About 30 mins to fix
      app/models/client.rb on lines 120..136
      app/models/provider.rb on lines 195..211

      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

      There are no issues that match your filters.

      Category
      Status