archivesspace/archivesspace

View on GitHub
backend/app/lib/job_runners/generate_slugs_runner.rb

Summary

Maintainability
F
1 wk
Test Coverage

Method run has a Cognitive Complexity of 161 (exceeds 5 allowed). Consider refactoring.
Open

  def run
    begin
      # SETUP
      @job.write_output("Resetting autogenerated slugs")
      @job.write_output("================================")
Severity: Minor
Found in backend/app/lib/job_runners/generate_slugs_runner.rb - About 3 days 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 run has 291 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def run
    begin
      # SETUP
      @job.write_output("Resetting autogenerated slugs")
      @job.write_output("================================")
Severity: Major
Found in backend/app/lib/job_runners/generate_slugs_runner.rb - About 1 day to fix

    File generate_slugs_runner.rb has 316 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class GenerateSlugsRunner < JobRunner
    
      register_for_job_type('generate_slugs_job',
                            {:create_permissions => :administer_system,
                             :cancel_permissions => :administer_system,
    Severity: Minor
    Found in backend/app/lib/job_runners/generate_slugs_runner.rb - About 3 hrs to fix

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

        def generate_slug_for(thing)
          slug = nil
          elapsed = Benchmark.measure do
            json_like_hash = thing.values
      
      
      Severity: Minor
      Found in backend/app/lib/job_runners/generate_slugs_runner.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

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

            AgentFamily.order(:id).paged_each do |r|
              r[:slug] = "" if r[:slug].nil?
              next if !r[:slug].empty? && r[:is_slug_auto] == 0
              begin
                @job.write_output("Generating slug for agent_family id: #{r[:id]}")
      Severity: Major
      Found in backend/app/lib/job_runners/generate_slugs_runner.rb and 3 other locations - About 3 hrs to fix
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 184..212
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 253..281
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 288..316

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

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

            AgentPerson.order(:id).paged_each do |r|
              r[:slug] = "" if r[:slug].nil?
      
              next if !r[:slug].empty? && r[:is_slug_auto] == 0
              begin
      Severity: Major
      Found in backend/app/lib/job_runners/generate_slugs_runner.rb and 3 other locations - About 3 hrs to fix
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 184..212
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 219..246
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 288..316

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

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

            AgentSoftware.order(:id).paged_each do |r|
              r[:slug] = "" if r[:slug].nil?
      
              next if !r[:slug].empty? && r[:is_slug_auto] == 0
              begin
      Severity: Major
      Found in backend/app/lib/job_runners/generate_slugs_runner.rb and 3 other locations - About 3 hrs to fix
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 184..212
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 219..246
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 253..281

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

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

            AgentCorporateEntity.order(:id).paged_each do |r|
              r[:slug] = "" if r[:slug].nil?
      
              next if !r[:slug].empty? && r[:is_slug_auto] == 0
              begin
      Severity: Major
      Found in backend/app/lib/job_runners/generate_slugs_runner.rb and 3 other locations - About 3 hrs to fix
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 219..246
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 253..281
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 288..316

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

      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

            Classification.any_repo.order(:id).paged_each do |r|
              r[:slug] = "" if r[:slug].nil?
      
              next if !r[:slug].empty? && r[:is_slug_auto] == 0
              begin
      Severity: Major
      Found in backend/app/lib/job_runners/generate_slugs_runner.rb and 6 other locations - About 2 hrs to fix
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 64..81
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 88..105
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 112..129
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 160..177
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 347..364
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 371..388

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

      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

            ClassificationTerm.any_repo.order(:id).paged_each do |r|
              r[:slug] = "" if r[:slug].nil?
      
              next if !r[:slug].empty? && r[:is_slug_auto] == 0
              begin
      Severity: Major
      Found in backend/app/lib/job_runners/generate_slugs_runner.rb and 6 other locations - About 2 hrs to fix
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 64..81
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 88..105
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 112..129
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 136..153
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 347..364
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 371..388

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

      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

            DigitalObject.any_repo.order(:id).paged_each do |r|
              r[:slug] = "" if r[:slug].nil?
      
              next if !r[:slug].empty? && r[:is_slug_auto] == 0
              begin
      Severity: Major
      Found in backend/app/lib/job_runners/generate_slugs_runner.rb and 6 other locations - About 2 hrs to fix
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 64..81
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 88..105
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 136..153
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 160..177
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 347..364
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 371..388

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

      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

            ArchivalObject.any_repo.order(:id).paged_each do |r|
              r[:slug] = "" if r[:slug].nil?
      
              next if !r[:slug].empty? && r[:is_slug_auto] == 0
              begin
      Severity: Major
      Found in backend/app/lib/job_runners/generate_slugs_runner.rb and 6 other locations - About 2 hrs to fix
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 64..81
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 88..105
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 112..129
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 136..153
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 160..177
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 371..388

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

      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

            DigitalObjectComponent.any_repo.order(:id).paged_each do |r|
              r[:slug] = "" if r[:slug].nil?
      
              next if !r[:slug].empty? && r[:is_slug_auto] == 0
              begin
      Severity: Major
      Found in backend/app/lib/job_runners/generate_slugs_runner.rb and 6 other locations - About 2 hrs to fix
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 64..81
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 88..105
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 112..129
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 136..153
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 160..177
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 347..364

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

      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

            Accession.any_repo.order(:id).paged_each do |r|
              r[:slug] = "" if r[:slug].nil?
      
              next if !r[:slug].empty? && r[:is_slug_auto] == 0
              begin
      Severity: Major
      Found in backend/app/lib/job_runners/generate_slugs_runner.rb and 6 other locations - About 2 hrs to fix
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 64..81
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 112..129
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 136..153
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 160..177
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 347..364
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 371..388

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

      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

            Resource.any_repo.order(:id).paged_each do |r|
              r[:slug] = "" if r[:slug].nil?
      
              next if !r[:slug].empty? && r[:is_slug_auto] == 0
              begin
      Severity: Major
      Found in backend/app/lib/job_runners/generate_slugs_runner.rb and 6 other locations - About 2 hrs to fix
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 88..105
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 112..129
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 136..153
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 160..177
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 347..364
      backend/app/lib/job_runners/generate_slugs_runner.rb on lines 371..388

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

      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