codeclimate/codeclimate-swiftlint

SwiftLint engine errors when handling certain custom rules

larkinscott opened this issue · 0 comments

Certain user-defined custom rules cause the SwiftLint engine to error on analysis. An example of this can be found in the SwiftLint repo itself (https://github.com/realm/SwiftLint):

D, [2018-03-01T20:09:09.845740 #1] DEBUG -- : engine stdout:

    {
    "categories": [
    "Style"
    ],
    "check_name": "Fatal Error",
    "description": "",
    "location": {
    "lines": {
      "begin": 1062,
      "end": 1062
    },
    "path": "CHANGELOG.md"

    },
    "severity": "critical",
    "type": "issue"
    }

    W, [2018-03-01T20:09:09.866849 #1]  WARN -- : killing container name=cc-engines-swiftlint-stable-c51235c6-22b4-4ea9-9f57-935c1d44a0ce message="output invalid"

    D, [2018-03-01T20:09:10.255119 #1] DEBUG -- : engine stderr: time="2018-03-01T20:09:10Z" level=fatal msg="write /dev/stdout: broken pipe"

    I, [2018-03-01T20:09:10.259333 #1]  INFO -- : finished engine swiftlint
    error: (CC::CLI::Analyze::EngineFailure) engine swiftlint failed with status 99 and stderr
    engine produced invalid output: {:message=>"Description must be present: `{\"categories\"=>[\"Style\"], \"check_name\"=>\"Fatal Error\", \"description\"=>\"\", \"location
    \"=>{\"lines\"=>{\"begin\"=>1062, \"end\"=>1062}, \"path\"=>\"CHANGELOG.md\"}, \"severity\"=>\"critical\", \"type\"=>\"issue\"}`.", :document=>{"categories"=>["Style"], "
    check_name"=>"Fatal Error", "description"=>"", "location"=>{"lines"=>{"begin"=>1062, "end"=>1062}, "path"=>"CHANGELOG.md"}, "severity"=>"critical", "type"=>"issue"}}

This particular rule seems to be omitting a description from the output, causing the engine to fail.

I found something similar occurring in Carthage (https://github.com/Carthage/Carthage):

    D, [2018-03-01T20:12:55.548491 #1] DEBUG -- : engine stdout:

    {
    "categories": [
      "Style"
    ],
    "check_name": "Missing Docs",
    "description": "",
    "location": {
      "lines": {
        "begin": 3,
        "end": 3
      },
      "path": "Source/CarthageKit/Resolver.swift"
    },
    "severity": "minor",
    "type": "issue"
    }

    W, [2018-03-01T20:12:55.564491 #1]  WARN -- : killing container name=cc-engines-swiftlint-stable-ca46b377-032a-4f77-a69c-530c22598a36 message="output invalid"

    I, [2018-03-01T20:12:55.917752 #1]  INFO -- : finished engine swiftlint
    error: (CC::CLI::Analyze::EngineFailure) engine swiftlint failed with status 99 and stderr
    engine produced invalid output: {:message=>"Description must be present: `{\"categories\"=>[\"Style\"], \"check_name\"=>\"Missing Docs\", \"description\"=>\"\", \"locatio
    n\"=>{\"lines\"=>{\"begin\"=>3, \"end\"=>3}, \"path\"=>\"Source/CarthageKit/Resolver.swift\"}, \"severity\"=>\"minor\", \"type\"=>\"issue\"}`.", :document=>{"categories"=["Style"], "check_name"=>"Missing Docs", "description"=>"", "location"=>{"lines"=>{"begin"=>3, "end"=>3}, "path"=>"Source/CarthageKit/Resolver.swift"}, "severity"=>"mino
    r", "type"=>"issue"}}