iagopiimenta/activestorage_legacy

View on GitHub

Showing 4 of 38 total issues

Class Blob has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

class ActiveStorage::Blob < ActiveRecord::Base
  self.table_name = "active_storage_blobs"

  attr_protected if defined?(attr_protected)
  include ActiveModel::ForbiddenAttributesProtection if defined?(ActiveModel::ForbiddenAttributesProtection)
Severity: Minor
Found in app/models/active_storage/blob.rb - About 2 hrs to fix

    Method update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def update
        if token = decode_verified_token
          if acceptable_content?(token)
            disk_service.upload token[:key], request.body, checksum: token[:checksum]
            head :no_content
    Severity: Minor
    Found in app/controllers/active_storage/disk_controller.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 verified has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def verified(signed_message, purpose: nil, **)
        if valid_message?(signed_message)
          begin
            data = signed_message.split("--".freeze)[0]
            message = ActiveSupport::MessagesMetadata.verify(decode(data), purpose)
    Severity: Minor
    Found in lib/active_storage/verifier.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 download has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def download(key)
        if block_given?
          instrument :streaming_download, key do
            File.open(path_for(key), "rb") do |file|
              while data = file.read(64.kilobytes)
    Severity: Minor
    Found in lib/active_storage/service/disk_service.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

    Severity
    Category
    Status
    Source
    Language