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
Reporterto 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
trueiff the--configparameter was used to specify (a) configuration file(s) In particular, this means that the value is alsotrueif the--configparameter was used to explicitly specify the default.swiftlint.ymlas 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
Configurationwith 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
configurationFilesThe path on disk to one or multiple configuration files. If this array is empty, the default
.swiftlint.ymlfile will be used.enableAllRulesEnable all available rules.
cachePathThe location of the persisted cache to use whith this configuration.
ignoreParentAndChildConfigsIf
true, child and parent config references will be ignored.mockedNetworkResultsFor testing purposes only. Instead of loading the specified urls, the mocked value will be used. Example: [“http://mock.com”: “content”]
useDefaultConfigOnFailureIf 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
Configurationwith itscomputedCacheDescriptionproperty set to the value ofcacheDescription, which is expensive to compute.Declaration
Swift
public func withPrecomputedCacheDescription() -> ConfigurationReturn Value
A new
Configurationvalue. -
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
pathThe parent path in which to search for lintable files. Can be a directory or a file.
forceExcludeWhether or not excludes defined in this configuration should be applied even if
pathis an exact match.excludeByPrefixWhether 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
fileManagerThe lintable file manager to use to expand the excluded paths into all matching paths.
pathsThe 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) -> ConfigurationParameters
fileThe 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 ) throwsParameters
dictThe untyped dictionary to serve as the input for this typed configuration. Typically generated from a YAML-formatted file.
ruleListThe list of rules to be available to this configuration.
enableAllRulesWhether all rules from
ruleListshould be enabled, regardless of the settings indict.cachePathThe 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
ruleIDThe 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 }
View on GitHub
Install in Dash
Configuration Structure Reference