-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flag to add Highest and Lowest Level Config Files (in Merge Tree) #1693
Comments
Thats awesome, thanks! I was thinking to open an issue, because as I see, many people need this feature. And your description of this feature is complete and clear. Also it would be great to have two flags for base and override. And we have to decide what |
I haven't given a lot of thought into this yet, but my initial impression is that |
I agree with |
I was thinking about implementation and discovered that ask |
Do you mean some sort of import statement? (I think there is a separate issue about that but I cannot find it now.) If so, while I see its usefulness as well, it doesn’t help my usage case. The whole point is for an overarching tool to be able to control SwiftLint’s basic defaults without having to write into the user’s configuration files. Writing to a configuration file in the repository is precisely what I want to be able to avoid.
I see its usefulness too, so I added it to the list at the top. (But please see my question about it there.) However, it is no help for the usage example above. By stopping all merging, it could cause a landslide of differences, not just the specific rule one is experimenting with. |
Yes
I think we could support both, but I think the more important one is in the configuration file. If that is supported, you could always create workarounds (e.g. generating files yourself).
IMO it would ignore nested configurations
Wouldn't that happen if you use |
No... maybe it needs a better name. This was the description:
I agree both should be supported. I also agree that import statements would affect more people. But it is a lot more work and thought to implement. P.S. Unless you tell me not to, I am planning on doing the work of implementing these myself and submitting a pull request. There is no point in starting until merging (#1687) is finalized, but I figured I could get the evaluation of names and semantics started in the meantime. |
@marcelofabri, I noted your answer about |
@SDGGiesbrecht you're right, I misunderstood
I think it's important for us to take some time and figure out the approach we want to go with to solve this family of problems, because they're all so related. If you want to go ahead and submit a PR, it'd be good to have a more concrete input for us to think, but I can't say for sure whether it'd be accepted or not. With that in mind, I'd ask you to do it only if it doesn't take so much effort. I also want to hear @jpsim about this and related features/requests. |
@marcelofabri, agreed on all counts. I thought more about the name I originally proposed the name thinking Is
Other suggestions anyone? |
I think we're overcomplicating this. Rubocop seems to take a much more simpler (and predictable) approach:
|
Thoughts on Rubocop:
SwiftLint does that. ✓
Simple and logical to me. On the other hand, several issues have already been registered because SwiftLint was getting configurations from outside the project/working directory. So I am not sure this is what users actually generally want. It also means SwiftLint can spit out different results when a repository is cloned to a different machine or location.
Logical without automatic merging (i.e. for Rubocop). Unclear semantics with automatic merging.
Wonderful and robust—definitely a good idea for the future. Requiring explicitness for the most common usage case (parent directory) is, however, very annoying (and goes against recent merged changes). Much of what is discussed here and provided in #1748 is just for the sake of thorough completeness. My primary motive is to be able to have a script analyze the project and provide more‐sensitive defaults, without modifying or overriding the project’s own configuration. The inheritance is thus: SwiftLint defaults ← scripted defaults ← project files. (I do not even particularly care how the in‐project files interact among themselves.) As far as I can tell, that is impossible with RuboCop. It is certainly impossible with SwiftLint right now, but SwiftLint defaults ← Reasons why
|
Closing along with #1748 to remove clutter. |
This takes over from @Aranoledur’s side track in #1687. Since this requires merging of nested configurations, this would be a future, independent enhancement after that is completed.
This is also the resurrection of @jpsim’s suggestion in #1323, now that the groundwork (merging, etc.) that was missing at the time is nearly finished.
I propose adding two flags that insert config files into the merge tree at the very top and very bottom.
Tentative flag names could be:
--base-config
: The file provided here would be treated as though it were parent to the.swiftlint.yml
file in the project’s root directory.--override-config
: The file provided here would be treated as though it were child to each of the deepest nested.swiftlint.yml
files. (This one needs a better name.)Edit: Here is a diagram of the merge tree:
--base-config
↳
/.swiftlint.yml
↳
--override-config
↳
/A/.swiftlint.yml
↳
--override-config
↳
/A/C/.swiftlint.yml
↳
--override-config
↳
/B/.swiftlint.yml
↳
--override-config
↳
/B/D/.swiftlint.yml
↳
--override-config
••••••• Edit •••••••
I will maintain an centralized list here of additional related flags proposed in later comments.
--no-merged-configurations
: Disables all merging (completely ignoring nested configurations).••••••• End Edit •••••••
(I don’t know the current semantics of
--config
. If useful, it could stick around to mean “use this configuration file and ignore all.swiftlint.yml
files.”)Example Usage
--base-config
Workspace recognizes when it is dealing with a Swift Package Manger project, and instructs SwiftLint to ignore dependencies out of the user’s control. As this currently trumps the user’s customization, the user must turn this automation off and figure it out themselves (#1637) if they want to customize SwiftLint. With
--base-config
, Workspace could simply use that and the user can still customize to their heart’s content (and even override individual pieces of Workspace’s default) using their own.swiftlint.yml
.--override-config
Let’s say you have a tree of nested config files, and you have a rule active at the root but disabled in several dozen subfolders. Now you want to see how much work it would be to make the disabled folders comply as well. As it stands, you have to remove the disabled rule from all of the dozen nested configs. With
--override-config
, you could simply enable it there, run SwiftLint, see the nightmare it would be to comply, and give up. That’s only one action, instead of thirteen (12 × enable + 1 revert).Anything to add, @Aranoledur?
The text was updated successfully, but these errors were encountered: