rumblelabs/asset_sync

View on GitHub
lib/asset_sync/storage.rb

Summary

Maintainability
D
2 days
Test Coverage

File storage.rb has 314 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "fog/core"

require "asset_sync/multi_mime"

module AssetSync
Severity: Minor
Found in lib/asset_sync/storage.rb - About 3 hrs to fix

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

      class Storage
        REGEXP_FINGERPRINTED_FILES = /\A(.*)\/(.+)-[^\.]+\.([^\.]+)\z/m
        REGEXP_ASSETS_TO_CACHE_CONTROL = /-[0-9a-fA-F]{32,}$/
    
        CONTENT_ENCODING = {
    Severity: Minor
    Found in lib/asset_sync/storage.rb - About 3 hrs to fix

      Method upload_file has 79 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def upload_file(f)
            # TODO output files in debug logs as asset filename only.
            one_year = 31557600
            ext = File.extname(f)[1..-1]
            mime = MultiMime.lookup(ext)
      Severity: Major
      Found in lib/asset_sync/storage.rb - About 3 hrs to fix

        Method upload_file has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

            def upload_file(f)
              # TODO output files in debug logs as asset filename only.
              one_year = 31557600
              ext = File.extname(f)[1..-1]
              mime = MultiMime.lookup(ext)
        Severity: Minor
        Found in lib/asset_sync/storage.rb - About 2 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 get_asset_files_from_manifest has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_asset_files_from_manifest
              if self.config.manifest
                if ActionView::Base.respond_to?(:assets_manifest)
                  log "Using: Rails 4.0 manifest access"
                  manifest = Sprockets::Manifest.new(ActionView::Base.assets_manifest.environment, ActionView::Base.assets_manifest.dir, self.config.manifest_path)
        Severity: Minor
        Found in lib/asset_sync/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 upload_files has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def upload_files
              # fixes: https://github.com/rumblelabs/asset_sync/issues/19
              local_files_to_upload = local_files - ignored_files - remote_files + always_upload_files
              local_files_to_upload = (local_files_to_upload + get_non_fingerprinted(local_files_to_upload)).uniq
              # Only files.
        Severity: Minor
        Found in lib/asset_sync/storage.rb - About 1 hr to fix

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

              def remote_files
                return [] if ignore_existing_remote_files?
                return @remote_files if @remote_files
          
                if remote_file_list_remote_path && remote_file_list_cache_file_path
          Severity: Minor
          Found in lib/asset_sync/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 upload_files has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def upload_files
                # fixes: https://github.com/rumblelabs/asset_sync/issues/19
                local_files_to_upload = local_files - ignored_files - remote_files + always_upload_files
                local_files_to_upload = (local_files_to_upload + get_non_fingerprinted(local_files_to_upload)).uniq
                # Only files.
          Severity: Minor
          Found in lib/asset_sync/storage.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

          There are no issues that match your filters.

          Category
          Status