Skip to content

swiftlint_version silently ignores incorrectly typed values #2518

Closed
@skagedal

Description

New Issue Checklist

Describe the bug

SwiftLint has a mechanism for pinning the tool to a specific version in the config file. One may write like this:

swiftlint_version: 0.29.1

And it will only run with that version of SwiftLint. If you write like this instead:

swiftlint_version: 0.29

It will also run. The user may think, as I did, that it has accepted 0.29.1 as being "at least" 0.29. That is however not what's happening, instead it is parsing 0.29 as a float and silently ignoring the directive. See Configuration+Parsing.swift, line 99.

Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint version
0.29.1
$ echo 'swiftlint_version: 0.29.1' > .swiftlint.yml
$ swiftlint                                        
Loading configuration from '.swiftlint.yml'
Linting Swift files at paths 
No lintable files found at paths: ''
$ echo 'swiftlint_version: 0.30.1' > .swiftlint.yml
$ swiftlint                                        
Loading configuration from '.swiftlint.yml'
Currently running SwiftLint 0.29.1 but configuration specified version 0.30.1.
$ echo 'swiftlint_version: 0.30' > .swiftlint.yml 
$ swiftlint                                      
Loading configuration from '.swiftlint.yml'
Linting Swift files at paths 
No lintable files found at paths: ''

Expected: that the last invocation of SwiftLint either printed "Currently running SwiftLint 0.29.1 but configuration specified version 0.30" or failed with "incorrect format for .swiftlint.yml"

Environment

  • SwiftLint version (run swiftlint version to be sure)?
    0.29.1

  • Installation method used (Homebrew, CocoaPods, building from source, etc)?
    Homebrew

  • Paste your configuration file:
    As above

  • Are you using nested configurations?
    If so, paste their relative paths and respective contents.
    No

  • Which Xcode version are you using (check xcode-select -p)?
    10.1

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions