Sha256: 29bc1f989d46bc4e6ac00b5a728f90471ac78a5145b620769e73a256df991698

Contents?: true

Size: 1.17 KB

Versions: 16

Compression:

Stored size: 1.17 KB

Contents

class Standard::CreatesConfigStore
  class ConfiguresIgnoredPaths
    DEFAULT_IGNORES = [
      # Match RuboCop's defaults: https://github.com/rubocop-hq/rubocop/blob/v0.61.1/config/default.yml#L60-L63
      ".git/**/*",
      "node_modules/**/*",
      "vendor/**/*",
      # Standard's own default ignores:
      "bin/*",
      "db/schema.rb",
      "tmp/**/*",
    ].map { |path| [path, ["AllCops"]] }.freeze

    def call(options_config, standard_config)
      ignored_patterns(standard_config).each do |(path, cops)|
        cops.each do |cop|
          options_config[cop] ||= {}
          options_config[cop]["Exclude"] ||= []
          options_config[cop]["Exclude"] |= [
            absolutify(standard_config[:config_root], path),
          ]
        end
      end
    end

    private

    def ignored_patterns(standard_config)
      (standard_config[:default_ignores] ? DEFAULT_IGNORES : []) +
        standard_config[:ignore]
    end

    def absolutify(config_root, path)
      if !absolute?(path)
        File.expand_path(File.join(config_root || Dir.pwd, path))
      else
        path
      end
    end

    def absolute?(path)
      path =~ %r{\A([A-Z]:)?/}
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
standard-0.1.10 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-0.1.9 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-0.1.8 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-0.1.7 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-0.1.6 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-0.1.5 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-0.1.4 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-0.1.3 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-0.1.2 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-0.1.1 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-0.1.0 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-0.0.41 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-0.0.40 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-0.0.39 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-0.0.38 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-0.0.37 lib/standard/creates_config_store/configures_ignored_paths.rb