-
Notifications
You must be signed in to change notification settings - Fork 29
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
fix: redundant-none-rule #324 #333
base: main
Are you sure you want to change the base?
fix: redundant-none-rule #324 #333
Conversation
wdl-lint/src/rules/redundant_none.rs
Outdated
wdl_ast::SyntaxKind::VersionStatementNode, | ||
wdl_ast::SyntaxKind::WorkflowDefinitionNode, | ||
wdl_ast::SyntaxKind::TaskDefinitionNode, | ||
wdl_ast::SyntaxKind::InputSectionNode, | ||
wdl_ast::SyntaxKind::BoundDeclNode, |
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.
wdl_ast::SyntaxKind::VersionStatementNode, | |
wdl_ast::SyntaxKind::WorkflowDefinitionNode, | |
wdl_ast::SyntaxKind::TaskDefinitionNode, | |
wdl_ast::SyntaxKind::InputSectionNode, | |
wdl_ast::SyntaxKind::BoundDeclNode, | |
wdl_ast::SyntaxKind::VersionStatementNode, | |
wdl_ast::SyntaxKind::InputSectionNode, | |
wdl_ast::SyntaxKind::BoundDeclNode, |
wdl-lint/src/rules/redundant_none.rs
Outdated
} | ||
|
||
fn tags(&self) -> TagSet { | ||
TagSet::new(&[Tag::Style]) |
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.
TagSet::new(&[Tag::Style]) | |
TagSet::new(&[Tag::Clarity]) |
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.
Personally, I'd tag it with both.
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.
Yea that's true. It should have both the Clarity
and Style
tag to be consistent with other similar rules.
|
||
fn explanation(&self) -> &'static str { | ||
"Optional inputs with explicit None assignments can be simplified. For example, \ | ||
String? foo = None can be shortened to String? foo." |
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.
@a-frantz - I don't particularly like this snippet from the spec (the variable names, that is), but showing that the two are equivalent could be helpful as part of this text. I've made a simple edit suggestion below, but I'm curious if you think a longer explanation
is preferable.
# the following are equivalent undefined optional declarations
String? maybe_five_but_is_not
String? also_maybe_five_but_is_not = None
String? foo = None can be shortened to String? foo." | |
`String? foo = None` is equivalent to and can be shortened to `String? foo`." |
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.
I'm ambivalent between your suggested edit and making it more verbose. I think the shorter text is "ok", but when the day comes that we create a dedicated website/wiki for all the lints, we might want to expand on it to include some "full" code snippets as examples. But given that we're currently only rendering this text in the terminal (from sprocket explain <rule>
), brevity might be preferable?
Co-authored-by: Andrew Frantz <[email protected]>
Co-authored-by: Andrew Frantz <[email protected]>
…3/wdl into redundant-none-issue
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.
please follow the instructions in the PR checklist to get this incorporated correctly. Your new rule isn't currently running, so we can't see what the diagnostics look like once rendered.
Co-authored-by: Andrew Frantz <[email protected]>
Co-authored-by: Andrew Frantz <[email protected]>
@a-frantz please can you tell me where i'm getting wrong and what should i do ? |
From the PR template checklist:
This is needed so that your new rule can execute in the tests. While you're at that, please go through the rest of the checklist and make any changes needed there. |
please fix all the errors reported by our CI before further review |
sure |
note[CallInputSpacing]: call input not properly spaced | ||
┌─ tests/lints/redudant-none/source.wdl:16:21 | ||
│ | ||
16 │ call test_task { |
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.
I'd fix this one and all of the non-relevant rules—we want tests to only show results for the specific rule that we are testing, not introduce unrelated warnings that need to be excepted.
input { | ||
String required_str | ||
Int? optional_int # should not flag, correct optional syntax | ||
String? optional_str = None # should flag, redundant None for optional |
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.
I don't see this one being flagged in the output.
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.
@claymcleod sorry ! I will check it soon
@a-frantz I will fix this soon |
@a-frantz |
Yes, you need to add documentation to everywhere that |
see this document for information about the failing checks |
3dc8137
to
f4c832c
Compare
START SECTION: adding a new linting rule
This pull request adds a new rule to
wdl-lint
.redundant-rule
fixes #324
added the lint rule that fires when = None is redundantly specified.
Before submitting this PR, please make sure:
CHANGELOG.md
(see"keep a changelog" for more information).
Rule specific checks:
RULES.md
.rules()
function inwdl-lint/src/lib.rs
.wdl-lint/tests/lints
that covers everypossible diagnostic emitted for the rule within the file where the rule
is implemented.
[ ] If you have implemented a newVisitor
callback, you have alsooverridden that callback method for the special
Validator
(
wdl-ast/src/validation.rs
) andLintVisitor
(
wdl-lint/src/visitor.rs
) visitors. These are required to ensure the newvisitor callback will execute.
gauntlet --refresh
to ensure that there are nounintended changes to the baseline configuration file (
Gauntlet.toml
).gauntlet --refresh --arena
to ensure that all of therules added/removed are now reflected in the baseline configuration file
(
Arena.toml
).