Configuration
public struct Configuration
extension Configuration: Hashable
extension Configuration: CustomStringConvertible
The configuration struct for SwiftLint. User-defined in the .swiftlint.yml
file, drives the behavior of SwiftLint.
-
The default Configuration resulting from an empty configuration file.
Declaration
Swift
public static var `default`: Configuration { get }
-
The default file name to look for user-defined configurations.
Declaration
Swift
public static let defaultFileName: String
-
The paths that should be included when linting
Declaration
Swift
public private(set) var includedPaths: [String] { get }
-
The paths that should be excluded when linting
Declaration
Swift
public private(set) var excludedPaths: [String] { get }
-
The style to use when indenting Swift source code.
Declaration
Swift
public let indentation: IndentationStyle
-
The threshold for the number of warnings to tolerate before treating the lint as having failed.
Declaration
Swift
public let warningThreshold: Int?
-
The identifier for the
Reporter
to use to report style violations.Declaration
Swift
public let reporter: String
-
The location of the persisted cache to use with this configuration.
Declaration
Swift
public let cachePath: String?
-
Allow or disallow SwiftLint to exit successfully when passed only ignored or unlintable files.
Declaration
Swift
public let allowZeroLintableFiles: Bool
-
This value is
true
iff the--config
parameter was used to specify (a) configuration file(s) In particular, this means that the value is alsotrue
if the--config
parameter was used to explicitly specify the default.swiftlint.yml
as the configuration fileDeclaration
Swift
public private(set) var basedOnCustomConfigurationFiles: Bool { get }
-
All rules enabled in this configuration
Declaration
Swift
public var rules: [Rule] { get }
-
The root directory is the directory that included & excluded paths relate to. By default, the root directory is the current working directory, but during some merging algorithms it may be used differently. The rootDirectory also serves as the stopping point when searching for nested configs along the file hierarchy.
Declaration
Swift
public var rootDirectory: String { get }
-
The rules mode used for this configuration.
Declaration
Swift
public var rulesMode: RulesMode { get }
-
init(configurationFiles:
enableAllRules: cachePath: ignoreParentAndChildConfigs: mockedNetworkResults: useDefaultConfigOnFailure: ) Creates a
Configuration
with convenience parameters.Declaration
Swift
public init( configurationFiles: [String], // No default value here to avoid ambiguous Configuration() initializer enableAllRules: Bool = false, cachePath: String? = nil, ignoreParentAndChildConfigs: Bool = false, mockedNetworkResults: [String: String] = [:], useDefaultConfigOnFailure: Bool? = nil )
Parameters
configurationFiles
The path on disk to one or multiple configuration files. If this array is empty, the default
.swiftlint.yml
file will be used.enableAllRules
Enable all available rules.
cachePath
The location of the persisted cache to use whith this configuration.
ignoreParentAndChildConfigs
If
true
, child and parent config references will be ignored.mockedNetworkResults
For testing purposes only. Instead of loading the specified urls, the mocked value will be used. Example: [“http://mock.com”: “content”]
useDefaultConfigOnFailure
If this value is specified, it will override the normal behavior. This is only intended for tests checking whether invalid configs fail.
-
Returns a copy of the current
Configuration
with itscomputedCacheDescription
property set to the value ofcacheDescription
, which is expensive to compute.Declaration
Swift
public func withPrecomputedCacheDescription() -> Configuration
Return Value
A new
Configuration
value. -
The style of indentation used in a Swift project.
See moreDeclaration
Swift
enum IndentationStyle : Hashable
-
Returns the files that can be linted by SwiftLint in the specified parent path.
Declaration
Swift
public func lintableFiles(inPath path: String, forceExclude: Bool, excludeByPrefix: Bool = false) -> [SwiftLintFile]
Parameters
path
The parent path in which to search for lintable files. Can be a directory or a file.
forceExclude
Whether or not excludes defined in this configuration should be applied even if
path
is an exact match.excludeByPrefix
Whether or not uses excluding by prefix algorithm.
Return Value
Files to lint.
-
Returns an array of file paths after removing the excluded paths as defined by this configuration.
Declaration
Swift
public func filterExcludedPaths( fileManager: LintableFileManager = FileManager.default, in paths: [String]... ) -> [String]
Parameters
fileManager
The lintable file manager to use to expand the excluded paths into all matching paths.
paths
The input paths to filter.
Return Value
The input paths after removing the excluded paths.
-
Returns the file paths that are excluded by this configuration using filtering by absolute path prefix.
For cases when excluded directories contain many lintable files (e. g. Pods) it works faster than default algorithm
filterExcludedPaths
.Declaration
Swift
public func filterExcludedPathsByPrefix(in paths: [String]...) -> [String]
Return Value
The input paths after removing the excluded paths.
-
Returns a new configuration that applies to the specified file by merging the current configuration with any nested configurations in the directory inheritance graph present until the level of the specified file.
Declaration
Swift
public func configuration(for file: SwiftLintFile) -> Configuration
Parameters
file
The file for which to obtain a configuration value.
Return Value
A new configuration.
-
Creates a Configuration value based on the specified parameters.
Declaration
Swift
public init( dict: [String: Any], ruleList: RuleList = primaryRuleList, enableAllRules: Bool = false, cachePath: String? = nil ) throws
Parameters
dict
The untyped dictionary to serve as the input for this typed configuration. Typically generated from a YAML-formatted file.
ruleList
The list of rules to be available to this configuration.
enableAllRules
Whether all rules from
ruleList
should be enabled, regardless of the settings indict
.cachePath
The location of the persisted cache on disk.
-
Returns the rule for the specified ID, if configured in this configuration.
Declaration
Swift
func configuredRule(forID ruleID: String) -> Rule?
Parameters
ruleID
The identifier for the rule to look up.
Return Value
The rule for the specified ID, if configured in this configuration.
-
Represents how a Configuration object can be configured with regards to rules.
See moreDeclaration
Swift
enum RulesMode
-
Declaration
Swift
public func hash(into hasher: inout Hasher)
-
Declaration
Swift
public static func == (lhs: Configuration, rhs: Configuration) -> Bool
-
Declaration
Swift
public var description: String { get }