garriguv / danger-ruby-swiftformat

A danger plugin to check Swift formatting using SwiftFormat.
MIT License
39 stars 15 forks source link

Error when processing options for disabled rules #47

Closed aclima93 closed 10 months ago

aclima93 commented 2 years ago

Description

When processing options for which their respective rule has been disabled, it will crash on check_format and issue an error

Produced outputs:

[!] Invalid Dangerfile file: Error running SwiftFormat: Error: error: Unknown option --typeblanklines. Did you mean --typemark? in configuration file.
 #  from Dangerfile
 #  -------------------------------------------
 >  swiftformat.check_format
 #  -------------------------------------------

Cause:

In .swiftformat, having --typeblanklines option with the blankLinesAtStartOfScope rule disabled as follows.

 --typeblanklines preserve

--disable \
    blankLinesAtStartOfScope
aclima93 commented 2 years ago

The current fix is to remove such idiosyncrasies, altough the CLI version of SwiftFormat seems to not have any issue with them.

garriguv commented 10 months ago

I think you have a good workaround 👍 It's better to have the configuration in a single place like .swiftformat.