mysociety/alaveteli

View on GitHub
lib/tasks/storage/storage.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Class Storage has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

class Storage
  def initialize(klass, association, setter: :data=, getter: :data,
                 condition: nil)
    @klass = klass
    @association = association
Severity: Minor
Found in lib/tasks/storage/storage.rb - About 2 hrs to fix

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

      def migrate
        count = unattached_files.count
    
        unattached_files.find_each.with_index do |file, index|
          Kernel.silence_warnings do
    Severity: Minor
    Found in lib/tasks/storage/storage.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 mirror has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      def mirror
        return puts(not_a_mirror) unless mirror_service?
        return puts(mirror_primary_not_disk_service) unless disk_service?
    
        count = mirrorable_blobs.count
    Severity: Minor
    Found in lib/tasks/storage/storage.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 promote has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Wontfix

      def promote
        return puts(not_a_mirror) unless mirror_service?
        return puts(mirror_primary_not_disk_service) unless disk_service?
    
        count = promotable_blobs.count
    Severity: Minor
    Found in lib/tasks/storage/storage.rb - About 45 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 unlink has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Wontfix

      def unlink
        return puts(not_a_mirror) unless mirror_service?
        return puts(mirror_primary_not_disk_service) unless disk_service?
    
        count = secondary_blobs.count
    Severity: Minor
    Found in lib/tasks/storage/storage.rb - About 45 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

    There are no issues that match your filters.

    Category
    Status