-
Notifications
You must be signed in to change notification settings - Fork 13
fix(cli): report error message when type scope or body empty #445
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,20 +27,12 @@ impl Rule for ScopeMaxLength { | |
| } | ||
|
|
||
| fn validate(&self, message: &Message) -> Option<Violation> { | ||
| match &message.scope { | ||
| Some(scope) => { | ||
| if scope.len() >= self.length { | ||
| return Some(Violation { | ||
| level: self.level.unwrap_or(Self::LEVEL), | ||
| message: self.message(message), | ||
| }); | ||
| } | ||
| } | ||
| None => { | ||
| if let Some(scope) = &message.scope { | ||
| if scope.len() >= self.length { | ||
| return Some(Violation { | ||
| level: self.level.unwrap_or(Self::LEVEL), | ||
| message: self.message(message), | ||
| }) | ||
| }); | ||
|
Comment on lines
+30
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix boundary condition: use strict “greater than” for max-length checks Same issue as type: equality with the limit should not violate, and length 0 shouldn’t violate when max is 0. Apply this diff: - if let Some(scope) = &message.scope {
- if scope.len() >= self.length {
+ if let Some(scope) = &message.scope {
+ if scope.len() > self.length {
return Some(Violation {
level: self.level.unwrap_or(Self::LEVEL),
message: self.message(message),
});
}
}🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -27,20 +27,12 @@ impl Rule for TypeMaxLength { | |||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| fn validate(&self, message: &Message) -> Option<Violation> { | ||||||||||||||||||||||||||||||||
| match &message.r#type { | ||||||||||||||||||||||||||||||||
| Some(t) => { | ||||||||||||||||||||||||||||||||
| if t.len() >= self.length { | ||||||||||||||||||||||||||||||||
| return Some(Violation { | ||||||||||||||||||||||||||||||||
| level: self.level.unwrap_or(Self::LEVEL), | ||||||||||||||||||||||||||||||||
| message: self.message(message), | ||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| None => { | ||||||||||||||||||||||||||||||||
| if let Some(t) = &message.r#type { | ||||||||||||||||||||||||||||||||
| if t.len() >= self.length { | ||||||||||||||||||||||||||||||||
| return Some(Violation { | ||||||||||||||||||||||||||||||||
| level: self.level.unwrap_or(Self::LEVEL), | ||||||||||||||||||||||||||||||||
| message: self.message(message), | ||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||
|
Comment on lines
+30
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix boundary condition: use strict “greater than” for max-length checks Max-length rules should pass when the length equals the limit. Using >= incorrectly flags values exactly at the configured maximum and also causes empty strings to violate when length is 0. Switch to >. Apply this diff: - if let Some(t) = &message.r#type {
- if t.len() >= self.length {
+ if let Some(t) = &message.r#type {
+ if t.len() > self.length {
return Some(Violation {
level: self.level.unwrap_or(Self::LEVEL),
message: self.message(message),
});
}
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix boundary condition: use strict “greater than” for max-length checks
Equality with the limit should pass. Using >= causes false positives and can still flag an empty body when limit is 0.
Apply this diff:
🤖 Prompt for AI Agents