Add 'nudge check' command for CI/linter usage#21
Merged
Conversation
Validates project files against configured rules, enabling use in CI pipelines or as a standalone linter. Usage: nudge check # Check all files nudge check src/ # Check specific directory nudge check "**/*.rs" # Check files matching pattern Exits 0 on success, 1 when issues found. Output is compact and human-readable, showing file:line locations and rule violations.
Apply fixes for real violations found by running nudge check on the codebase: - Replace std::fs::*, std::process::*, std::fmt::*, etc. with imports - Use turbofish syntax instead of LHS type annotations where possible - Move inline imports to file top (std::sync::Mutex in schema.rs) - Add pretty_assertions import to test modules and convert assert_eq! Remaining violations are false positives due to rule pattern issues: - prefer-pretty-assertions: pattern matches substring in pretty_assert_eq! - no-lhs-type-annotations: matches pattern matching (let Value::Object) and required type annotations on generic functions (serde) - no-inline-imports: matches idiomatic use super::* in test modules - no-unwrap: matches .unwrap() in doc comments and string literals
- Convert 4 rules from regex to tree-sitter to eliminate false positives: - prefer-pretty-assertions: matches macro_invocation instead of substring - no-lhs-type-annotations: matches let_declaration with type annotation - no-inline-imports: matches use inside block, not test modules - no-unwrap: matches actual method calls, avoiding doc comments/strings - Replace all .unwrap() calls with .expect() for better error messages - 11 fixes in schema.rs test code - 1 fix in rules.rs test code - 2 fixes in snippet.rs test code - 9 fixes in bash.rs integration tests - 13 fixes in other integration test files - 4 fixes in build.rs and cmd modules All 96 tests pass and nudge check reports zero violations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds a new
nudge checkcommand that validates project files against configured rules, designed for CI pipelines and local linting..gitignoreand ignores hidden files/directoriesUsage
Dogfooding: Before & After
We ran
nudge checkon this repository to validate it works. Here's what we found and fixed:Before (42 violations found)
After (0 violations)
Changes
New
nudge checkcommand (src/cmd/check.rs).gitignoreUpdated rules to use tree-sitter (
.nudge.yaml)prefer-pretty-assertions: Avoids false positive onpretty_assert_eq!no-lhs-type-annotations: Avoids false positive on pattern matchingno-inline-imports: Ignoresuseinmod testsblocksno-unwrap: Matches method calls only, not doc comments/stringsFixed all violations in source and test files
.unwrap()with.expect()(36 occurrences)Testing
nudge checkreports zero violations on this repository