Add basic infrastructure for XCLinter #3
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 withinXCLinter
: 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 aninit
that accepts theConfiguration
and a singlerun()
method.Violation
s are returned by aRule
representing any rule violations that occur. I'm not sure what exactly will be needed by this type, but for now it just has amessage
and optionally an array ofPBXObject
s.XCLintError
, a simple Error type thrown when setting upXCLinter
. 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 outConfiguration
. 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 itsrun()
method which will iteratively initialize and run each rule, collecting anyViolation
s. 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!