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

Add basic infrastructure for XCLinter #3

Merged
merged 2 commits into from
Oct 15, 2023

Conversation

aidaan
Copy link
Contributor

@aidaan aidaan commented Oct 15, 2023

This adds some basic infrastructure for the linter:

  • XCLinter is a new primary type within the XCLinting module. It is used to run a linting operation.
  • Configuration contains basic information for use within XCLinter: the parsed project file, the string contents of the project file, and the location of the project file on disk. Since this type will be passed around frequently, I made it an immutable class, to avoid any expensive copies. I expect this type to grow over time to include things like folder/groups to skip and any other options.
  • Rule is a protocol that establishes the interface for each lint rule that might be defined. Pretty simple for now, just an init that accepts the Configuration and a single run() method.
  • Violations are returned by a Rule representing any rule violations that occur. I'm not sure what exactly will be needed by this type, but for now it just has a message and optionally an array of PBXObjects.
  • Finally there's XCLintError, a simple Error type thrown when setting up XCLinter. Again, not quite sure what else will be needed in here, but for it contains a few simple file errors when reading in the project file.

XCLinter can be initialized with a path to the project file or with a fleshed out Configuration. When supplied with a path, it will attempt to read in and parse the project file, throwing errors if anything fails. I added a couple simple tests around these errors, just to get the ball rolling on tests.

Once setup, XCLinter has its run() method which will iteratively initialize and run each rule, collecting any Violations. If any violations are found, the command line exits with code 1, printing the messages from the violations. Otherwise exit with code 0.

I realize this is a ton of code to add to your project. Feel free to comment or edit any of it. I'm very interested in this topic and would love to see this project succeed. Thank you!

@mattmassicotte
Copy link
Owner

Ok, so first I just wanted to clarify how I generally approach contributions. I have a very strong bias towards enthusiasm. I care a lot more about everyone feeling good and making progress than I do about some making some kind of "perfect" PR. There are exceptions of course, like if a package is used a lot and there's some breaking/risky changes. But for a project so young, I'm pretty much into any and all changes.

There are a few things I want to look more closely at as we move towards some kind of functional thing. In particular, the Rule concept. But I haven't thought deeply about any of this and it's pretty clear you have. So let's do this!

@mattmassicotte mattmassicotte merged commit 97c9217 into mattmassicotte:main Oct 15, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants