realm / SwiftLint

A tool to enforce Swift style and conventions.
https://realm.github.io/SwiftLint
MIT License
18.46k stars 2.2k forks source link

SwiftLintPlugin does not honor `included` configuration. Issue? Or expected? #5515

Closed mstanzianoinsulet closed 3 months ago

mstanzianoinsulet commented 3 months ago

New Issue Checklist

Describe the bug

I've recently switched to using the SwiftLint Build Tool Plugin and noticed that it does not appear to honor the included configuration within .swiftlint.yml. I have 1 .swiftlint.yml in the main App target directory, and it includes other directories that live at the same level - referenced as shown in the example below.

Is this expected to work? Or is it a limitation of using the Build Tool Plugin?

Environment

included:
 - ../OtherDirectory
SimplyDanny commented 3 months ago

I think that configuration files cannot be read from places outside of the project structure due to Xcode executing plugins in a sandboxed environment.

But I'm not expert here, admittedly. @garricn, @tinder-cfuller: Can you help out?

tinder-cfuller commented 3 months ago

In this case, included is for including Swift files, not configuration files. @SimplyDanny is correct though, the plugin relies on the inputFiles it is provided and passes those as arguments to the executable invocation.

https://github.com/garricn/SwiftLint/blob/9c216baf2094668cb1db834a73348d84cbe2f02c/Plugins/SwiftLintPlugin/SwiftLintPlugin.swift#L19

https://github.com/garricn/SwiftLint/blob/9c216baf2094668cb1db834a73348d84cbe2f02c/Plugins/SwiftLintPlugin/SwiftLintPlugin.swift#L40

And it makes sense that when paths are passed as arguments to the executable, it then ignores the included option.

The reason the plugin uses the inputFiles is that these are the files that belong to the target being built. So from the plugin perspective these are the only files that would need to be linted.

tinder-cfuller commented 3 months ago

@mstanzianoinsulet The next release of SwiftLint includes improvements to the build plugin and now also includes a command plugin too. The command plugin could be used for your setup since I see no reason why it would not respect the included option (it is not provided with inputFiles for example).

#4758 - Use BUILD_WORKSPACE_DIRECTORY in SwiftLintPlugin #5497 - Introduce SwiftLintCommandPlugin

mstanzianoinsulet commented 3 months ago

Thank you so much @tinder-cfuller & @SimplyDanny 👍 I'm going to close this and see what I can do with the new implementation.