Skip to content
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

SwiftPM skip dependencies by default #1637

Closed
thislooksfun opened this issue Jun 21, 2017 · 6 comments
Closed

SwiftPM skip dependencies by default #1637

thislooksfun opened this issue Jun 21, 2017 · 6 comments

Comments

@thislooksfun
Copy link

When running swiftlint in an SPM project it recursively lints all the dependencies as well, which is almost never useful behavior, since the dependencies are out of the control of the user running the command. I'm aware the workaround is to only run swiftlint in the Sources and Tests directories or to use the excludes directive, but it still seems like this should be the default behavior.

@marcelofabri
Copy link
Collaborator

I don't agree that this should be the default behavior, since people can use different structures for their project and/or want that the dependencies are linted as well.

@SDGGiesbrecht
Copy link
Contributor

SDGGiesbrecht commented Jun 23, 2017

@marcelofabri

Ignoring uneditable dependencies seems like a reasonable default to me.

[P]eople [may] want that the dependencies are linted as well[.]

By default, you could ignore .build, but still lint Packages.

Since Swift 3, packages only appear in the Packages folder if the user specifies that they should be editable by running the command swift package edit .... More information available in the Swift Package Manager’s own documentation.

It would be very bad practice to make changes to a normal, uneditable package hiding inside .build. I do not think it makes sense for SwiftLint to suggest to users to make such changes—which is effectively what it does when it reports a violation there.

[P]eople can use different structures for their project[.]

I am aware of this. But do you really think someone will ever put source code in folder named .build?

If you are still not satisfied, you could always add a command line flag --package that could be used to tell SwiftLint that it is dealing with a Swift package and can safely make assumptions based on the semantics of a package’s directory structure. SwiftLint could then modify its default behaviour accordingly.

(Actually, since the Swift Package Manager is part of the language itself, and I see no conflict with Xcode, it would probably make more sense to instead implement it as opt‐out—a --not-a-package flag for projects with exotic structures.)


@thislooksfun,

I’m aware the workaround is to only run swiftlint in the Sources and Tests directories[.]

That will not lint Package.swift or similar files. I would advise using excluded with .build.

Or, have a look at Workspace, which I wrote to corral SwiftLint and other tools into interoperating better with the Swift Package Manager. Making SwiftLint skip dependencies is one of the things it automates.

@marcelofabri
Copy link
Collaborator

By default, you could ignore .build, but still lint Packages.

I thought the issue was talking about Packages, not .build. I think in this case it might make sense to exclude .build by default, but I'd say that if you specify excluded in your config, you should add .build to it.

@thislooksfun
Copy link
Author

Yeah, that's what I'm doing now and it's working just fine.

@stale
Copy link

stale bot commented Nov 8, 2020

This issue has been automatically marked as stale because it has not had any recent activity. Please comment to prevent this issue from being closed. Thank you for your contributions!

@tumata
Copy link

tumata commented Jun 29, 2021

This caused me confusion today. I'll exclude it as mentioned above, but I agree that is should be disabled by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants