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

Fail if metadata.json has no proper newline #154

Merged
merged 1 commit into from
Jan 24, 2025

Conversation

bastelfreak
Copy link
Member

Should be rebased after #152 is merged.

Since ages, it's in our style guide that files need to end with a newline (https://voxpupuli.org/docs/reviewing_pr/), also the FHS demands it.

lib/metadata_json_lint.rb Outdated Show resolved Hide resolved
Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking out loud: is there a chance someone runs this interactively and passes it in via stdin? It may be too much of an edge case to care about, but users may do echo '{}' | metadata-json-lint /dev/stdin to only verify the schema. I can see editors with language servers apply this technique.

@bastelfreak
Copy link
Member Author

echo '{}' | metadata-json-lint /dev/stdin works with this branch and on the master branch

$ echo '{}' | bundle exec metadata-json-lint /dev/stdin
(ERROR) required_fields: The file did not contain a required property of 'author'
(ERROR) required_fields: The file did not contain a required property of 'dependencies'
(ERROR) required_fields: The file did not contain a required property of 'license'
(ERROR) required_fields: The file did not contain a required property of 'name'
(ERROR) required_fields: The file did not contain a required property of 'source'
(ERROR) required_fields: The file did not contain a required property of 'summary'
(ERROR) required_fields: The file did not contain a required property of 'version'
Errors found in /dev/stdin

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

echo '{}' | metadata-json-lint /dev/stdin works with this branch and on the master branch

That surprises me. I'd have expected that to fail on a missing newline. Now that I think about it, echo adds that. So a way to force this failure is echo -n '{}' | metadata-json-lint /dev/stdin

lib/metadata_json_lint.rb Outdated Show resolved Hide resolved
tests/missing_newline/metadata.json Outdated Show resolved Hide resolved
Since ages, it's in our style guide that files need to end with a
newline (https://voxpupuli.org/docs/reviewing_pr/), also the FHS demands
it.
@bastelfreak bastelfreak merged commit cd27d48 into voxpupuli:master Jan 24, 2025
8 checks passed
@bastelfreak bastelfreak deleted the slashn branch January 24, 2025 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants