Skip to content

Improve MixedIndentation rule to always emit notes for … #401

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

Closed

Conversation

Gyan-max
Copy link
Contributor

@Gyan-max Gyan-max commented Apr 8, 2025

…document-level indentation issues and warnings for command sections

START SECTION:

This PR improves the MixedIndentation rule to consistently detect and report mixed indentation issues throughout WDL documents.

The improvement includes:

  • Emitting notes for document-level mixed indentation consistently throughout the entire document.
  • Continuing to check for more instances of mixed indentation after finding the first occurance
  • Updated the RULES.md to reflect the functionality

Before submitting this PR, please make sure:

  • You have added a few sentences describing the PR here.
  • You have added yourself or the appropriate individual as the assignee.
  • You have added at least one relevant code reviewer to the PR.
  • Your code builds clean without any errors or warnings.
  • You have added an entry to the relevant CHANGELOG.md (see
    "keep a changelog" for more information).
  • Your commit messages follow the conventional commit style.
  • Your PR title follows the conventional commit style.

Rule specific checks:

  • You have added the rule as an entry within RULES.md.
  • You have added the rule to the rules() function in wdl-lint/src/lib.rs.
  • You have added a test case in wdl-lint/tests/lints that covers every
    possible diagnostic emitted for the rule within the file where the rule
    is implemented.
  • If you have implemented a new Visitor callback, you have also
    overridden that callback method for the special Validator
    (wdl-ast/src/validation.rs) and LintVisitor
    (wdl-lint/src/visitor.rs) visitors. These are required to ensure the new
    visitor callback will execute.
  • You have run gauntlet --bless to ensure that there are no
    unintended changes to the baseline configuration file (Gauntlet.toml).
  • You have run gauntlet --bless --arena to ensure that all of the
    rules added/removed are now reflected in the baseline configuration file
    (Arena.toml).

Close #201

@adthrasher
Copy link
Member

@Gyan-max - Please complete the PR checklist.

@@ -578,7 +578,7 @@ permalink = "https://github.com/aws-samples/amazon-omics-tutorials/blob/c624acf2

[[diagnostics]]
document = "biowdl/tasks:/bcftools.wdl"
message = 'bcftools.wdl:114:75: error: unknown escape sequence `\_`'
message = "bcftools.wdl:114:75: error: unknown escape sequence `/_`"
Copy link
Member

Choose a reason for hiding this comment

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

This isn't for this PR, but this escape is in a parameter_meta entry. I suspect the associated rule is too broad.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes,
It's incorrectly flagging valid characters like \_ and /_ as invalid escape sequences in parameter metadata descriptions.
I don't know why but these characters are valid in parameter metadata description and i think they should not be flagged as errors.

@adthrasher
Copy link
Member

@Gyan-max - Please complete the PR checklist.

I guess I need to clarify. The following three items are checked in your checklist above, but are not done. Please fix them.

You have added yourself or the appropriate individual as the assignee.
You have added at least one relevant code reviewer to the PR.
Your code builds clean without any errors or warnings.

@github-actions github-actions bot added the S-awaiting-CI State: awaiting the CI to pass label Apr 8, 2025
@Gyan-max
Copy link
Contributor Author

Gyan-max commented Apr 8, 2025

@Gyan-max - Please complete the PR checklist.

I guess I need to clarify. The following three items are checked in your checklist above, but are not done. Please fix them.

You have added yourself or the appropriate individual as the assignee.
You have added at least one relevant code reviewer to the PR.
Your code builds clean without any errors or warnings.

Sorry for the confusion in the checklist.
Can you guide me on how can I add assignee and code reviewers
like do I have to mention them or what?

@adthrasher
Copy link
Member

image

@Gyan-max
Copy link
Contributor Author

Gyan-max commented Apr 9, 2025

image

I think I don't have permission to add assignee and code reviewer.

@a-frantz
Copy link
Member

a-frantz commented Apr 9, 2025

I think I don't have permission to add assignee and code reviewer.

that's good to know, thanks. You still need to fix the failing tests though. We can handle the assigning portions.

@Gyan-max Gyan-max changed the title Improve CommandSectionMixedIndentation rule to always emit notes for … Improve MixedIndentation rule to always emit notes for … Apr 9, 2025
@Gyan-max
Copy link
Contributor Author

Gyan-max commented Apr 9, 2025

@a-frantz I don't know why there are so many Cl failed tests, initially there was only 3, can you please review my commits and guide me how to fix them

use crate::Tag;
use crate::TagSet;
use crate::tags::Tag;
use crate::tags::TagSet;
use crate::util::lines_with_offset;

/// The identifier for the command section mixed indentation rule.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// The identifier for the command section mixed indentation rule.
/// The identifier for the mixed indentation rule.

│ ------- this command section uses both tabs and spaces in leading whitespace
13 │ this line has a continuation /
14 │ and should be a warning
│ ^^^ indented with spaces until this tab
Copy link
Member

Choose a reason for hiding this comment

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

This is a regression. This rule should flag the position where the spacing changed types.

Copy link
Member

Choose a reason for hiding this comment

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

Where is the associated test file?

Copy link
Member

Choose a reason for hiding this comment

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

Same here?

Copy link
Member

Choose a reason for hiding this comment

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

These lints need to get cleaned up if they're not relevant to what is being tested.

@@ -30,6 +30,14 @@ note[Whitespace]: line contains only whitespace
= fix: remove the whitespace

note[CommandSectionMixedIndentation]: mixed indentation throughout document
Copy link
Member

Choose a reason for hiding this comment

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

This isn't a command section, so the rule name is incorrect.

Copy link
Member

Choose a reason for hiding this comment

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

Nothing should have changed in this file.

@Gyan-max
Copy link
Contributor Author

Gyan-max commented Apr 9, 2025

@adthrasher I tried to address all your feedback,
Please review the commits

Copy link
Member

Choose a reason for hiding this comment

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

Where did these changes come from?

Comment on lines 5 to 6
/// Rules for detecting mixed indentation (spaces and tabs) in WDL command
/// sections and documents.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Rules for detecting mixed indentation (spaces and tabs) in WDL command
/// sections and documents.

There are no other comments in this list.

Copy link
Member

@adthrasher adthrasher left a comment

Choose a reason for hiding this comment

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

Please respond in writing to the review comments before pushing additional changes

@@ -2,6 +2,7 @@

mod blank_lines_between_elements;
mod call_input_spacing;
#[doc = "Module for detecting mixed indentation in command sections and documents."]
Copy link
Member

Choose a reason for hiding this comment

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

This is the second time you've added a comment to this file. Instead of deleting it, can you reply and explain why you made this change?

Copy link
Member

Choose a reason for hiding this comment

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

Why did this file change? It looks like you just reordered these entries, what was the motivation behind that decision?

@@ -334,7 +334,7 @@ fn bump(version: &str, patch_bump: bool) -> String {

/// Publishes a crate.
async fn publish(name: &str, version: &str, manifest_path: &Path, dry_run: bool) -> bool {
if !SORTED_CRATES_TO_PUBLISH.iter().any(|s| *s == name) {
if !SORTED_CRATES_TO_PUBLISH.contains(&name) {
Copy link
Member

Choose a reason for hiding this comment

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

Why did this change?

Comment on lines +26 to +27
/// Type alias for backward compatibility
pub type CommandSectionMixedIndentationRule = MixedIndentationRule;
Copy link
Member

Choose a reason for hiding this comment

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

Why are we concerned about backwards compatibility here?

#[derive(Default, Debug, Clone)]
pub struct MixedIndentationRule {
/// The visitor that does the actual work.
visitor: MixedIndentationVisitor,
Copy link
Member

Choose a reason for hiding this comment

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

This is a departure from all of the existing lint rules. Why does this rule need a Visitor member instead of simply implementing the trait for the rule?

}

fn related_rules(&self) -> &[&'static str] {
&[]
&["Whitespace"]
Copy link
Member

Choose a reason for hiding this comment

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

How is the Whitespace rule related to this rule?

Copy link
Member

Choose a reason for hiding this comment

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

Why did this file change?

@Gyan-max
Copy link
Contributor Author

@adthrasher Sorry for soo much commits, I was just trying to fix the Cl failed tests and in order to fix it I somewhere messed up with code logic and implementation.
I need your guidance for Cl test failures.
and i again request you to please review my code and suggest me fixes that I should make in order to implement this rule.

@adthrasher
Copy link
Member

@adthrasher Sorry for soo much commits, I was just trying to fix the Cl failed tests and in order to fix it I somewhere messed up with code logic and implementation. I need your guidance for Cl test failures. and i again request you to please review my code and suggest me fixes that I should make in order to implement this rule.

Before we go any further, please respond to the questions I left in my last review. This PR has grown to a much larger set of changes than I would expect and I want to understand how it got to be that way. So if you could explain the changes you've made so far, that'd be great.

@Gyan-max
Copy link
Contributor Author

@adthrasher Sorry for soo much commits, I was just trying to fix the Cl failed tests and in order to fix it I somewhere messed up with code logic and implementation. I need your guidance for Cl test failures. and i again request you to please review my code and suggest me fixes that I should make in order to implement this rule.

Before we go any further, please respond to the questions I left in my last review. This PR has grown to a much larger set of changes than I would expect and I want to understand how it got to be that way. So if you could explain the changes you've made so far, that'd be great.

Sure

@Gyan-max
Copy link
Contributor Author

Gyan-max commented Apr 10, 2025

I think I messed up the whole PR, just to resolve the Cl test failure. If you allow can I make a fresh start from scratch?

@adthrasher
Copy link
Member

Per @Gyan-max, closing this PR.

@adthrasher adthrasher closed this Apr 10, 2025
@Gyan-max Gyan-max deleted the fix-document-mixed-indentation branch April 11, 2025 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-awaiting-CI State: awaiting the CI to pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lint rules for mixed indentation
3 participants