Sha256: e9634daddf03b9e810b0fa77491da0395a27ca4c0276e6b6027ca08e6ee554c6

Contents?: true

Size: 1.16 KB

Versions: 204

Compression:

Stored size: 1.16 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

204 entries across 204 versions & 5 rubygems

Version Path
standard-1.47.0 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-1.46.0 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-1.45.0 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-1.44.0 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-1.43.0 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-1.42.1 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-1.42.0 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-1.41.1 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-1.41.0 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-1.40.1 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-1.40.0 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-1.39.2 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-1.39.1 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-1.39.0 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-1.38.0 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-1.37.0 lib/standard/creates_config_store/configures_ignored_paths.rb
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/creates_config_store/configures_ignored_paths.rb
standard-1.35.0.1 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-1.34.0.1 lib/standard/creates_config_store/configures_ignored_paths.rb
standard-1.35.1 lib/standard/creates_config_store/configures_ignored_paths.rb