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.

Properties: Static

  • The default Configuration resulting from an empty configuration file.

    Declaration

    Swift

    public static var `default`: `Self` { get }
  • The default file name to look for user-defined configurations.

    Declaration

    Swift

    public static let defaultFileName: String

Public Instance

  • 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
  • Treat warnings as errors.

    Declaration

    Swift

    public let strict: Bool
  • Treat errors as warnings.

    Declaration

    Swift

    public let lenient: Bool
  • The path to read a baseline from.

    Declaration

    Swift

    public let baseline: String?
  • The path to write a baseline to.

    Declaration

    Swift

    public let writeBaseline: String?
  • Check for updates.

    Declaration

    Swift

    public let checkForUpdates: 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 also true if the --config parameter was used to explicitly specify the default .swiftlint.yml as the configuration file

    Declaration

    Swift

    public private(set) var basedOnCustomConfigurationFiles: Bool { get }

Public Computed

  • All rules enabled in this configuration

    Declaration

    Swift

    public var rules: [any 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 }

Public

  • Creates a Configuration with convenience parameters.

    Declaration

    Swift

    public init(
        configurationFiles: [String], // No default value here to avoid ambiguous Configuration() initializer
        enableAllRules: Bool = false,
        onlyRule: [String] = [],
        cachePath: String? = nil,
        ignoreParentAndChildConfigs: Bool = false,
        mockedNetworkResults: [String: String] = [:],
        useDefaultConfigOnFailure: Bool? = nil // swiftlint:disable:this discouraged_optional_boolean
    )

    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.

Hashable

CustomStringConvertible