rumblelabs/asset_sync

View on GitHub

Showing 18 of 18 total issues

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

    def load_yml!
      self.enabled                = yml["enabled"] if yml.has_key?('enabled')
      self.fog_provider           = yml["fog_provider"]
      self.fog_host               = yml["fog_host"]
      self.fog_port               = yml["fog_port"]
Severity: Minor
Found in lib/asset_sync/config.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 fog_options has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    def fog_options
      options = { :provider => fog_provider }
      if aws?
        if aws_iam?
          options.merge!({
Severity: Minor
Found in lib/asset_sync/config.rb - About 5 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

File config.rb has 350 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "active_model"
require "erb"

module AssetSync
  class Config
Severity: Minor
Found in lib/asset_sync/config.rb - About 4 hrs to fix

    Class Config has 30 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Config
        include ActiveModel::Validations
    
        class Invalid < StandardError; end
    
    
    Severity: Minor
    Found in lib/asset_sync/config.rb - About 3 hrs to fix

      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 fog_options has 59 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def fog_options
                  options = { :provider => fog_provider }
                  if aws?
                    if aws_iam?
                      options.merge!({
            Severity: Major
            Found in lib/asset_sync/config.rb - About 2 hrs to fix

              Method load_yml! has 57 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def load_yml!
                    self.enabled                = yml["enabled"] if yml.has_key?('enabled')
                    self.fog_provider           = yml["fog_provider"]
                    self.fog_host               = yml["fog_host"]
                    self.fog_port               = yml["fog_port"]
              Severity: Major
              Found in lib/asset_sync/config.rb - About 2 hrs to fix

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

                  class InstallGenerator < Rails::Generators::Base
                    desc "Install a config/asset_sync.yml and the asset:precompile rake task enhancer"
                
                    # Commandline options can be defined here using Thor-like options:
                    class_option :use_yml,   :type => :boolean, :default => false, :desc => "Use YML file instead of Rails Initializer"
                Severity: Minor
                Found in lib/generators/asset_sync/install_generator.rb - About 2 hrs to fix

                  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 with_config has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def with_config(&block)
                          return unless AssetSync.enabled?
                    
                          errors = config.valid? ? "" : config.errors.full_messages.join(', ')
                    
                    
                    Severity: Minor
                    Found in lib/asset_sync/asset_sync.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

                    Avoid deeply nested control flow statements.
                    Open

                          elsif backblaze?
                            require 'fog/backblaze'
                            options.merge!({
                              :b2_key_id      => b2_key_id,
                              :b2_key_token   => b2_key_token,
                    Severity: Major
                    Found in lib/asset_sync/config.rb - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                              options.merge!({:environment => fog_region}) if fog_region
                      Severity: Major
                      Found in lib/asset_sync/config.rb - About 45 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language