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

feat: add non-matching output lint rule #114

Merged
merged 35 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d7929c5
feat: add non-matching output lint rule
adthrasher Jul 9, 2024
81dd295
chore: add PR # to CHANGELOG
adthrasher Jul 9, 2024
20665a5
chore: add document reset
adthrasher Jul 9, 2024
afdd6cd
Merge branch 'main' into feat/nonmatching_output
adthrasher Jul 9, 2024
339ec53
Merge branch 'feat/nonmatching_output' of https://github.com/stjude-r…
adthrasher Jul 9, 2024
1180cbe
Merge branch 'main' into feat/nonmatching_output
adthrasher Jul 9, 2024
7efddb2
chore: add exceptions and skip empty `output` sections
adthrasher Jul 9, 2024
0af033d
chore: add key name to diagnostic
adthrasher Jul 9, 2024
f5a0d15
chore: fix tags
adthrasher Jul 9, 2024
a0d5229
chore: remove extra blank line
adthrasher Jul 9, 2024
6d46d62
chore: add test for non-matching output
adthrasher Jul 10, 2024
e0fbd60
chore: add task or workflow name to diagnostics
adthrasher Jul 10, 2024
ffb998b
chore: add order check and extraneous items
adthrasher Jul 10, 2024
b964609
Apply suggestions from code review
adthrasher Jul 11, 2024
d1f31b5
Apply suggestions from code review
adthrasher Jul 11, 2024
4adcd2a
Apply suggestions from code review
adthrasher Jul 11, 2024
c8f8f9b
chore: add check for non-object `outputs` key
adthrasher Jul 11, 2024
93d7615
chore: use `output` for OutputSection
adthrasher Jul 11, 2024
75a84ef
chore: add test with empty output
adthrasher Jul 11, 2024
4effe6c
chore: add tests for lint exceptions
adthrasher Jul 11, 2024
4646473
refactor: process individual entries to enable `#@ except`
adthrasher Jul 11, 2024
950e3cd
refactor: store prior objects
adthrasher Jul 12, 2024
f2daa18
chore: apply PR feedback
adthrasher Jul 12, 2024
85b3c13
chore: String -> &str for diagnostics
adthrasher Jul 12, 2024
419a4d6
chore: cargo fmt
adthrasher Jul 12, 2024
3eba4a1
Apply suggestions from code review
adthrasher Jul 15, 2024
714638f
chore: rephrase descriptions
adthrasher Jul 15, 2024
470ef8d
refactor: pull common functionality into a function
adthrasher Jul 16, 2024
ddd13b8
refactor: track section enter/exit
adthrasher Jul 16, 2024
7dc4ace
chore: fmt
adthrasher Jul 16, 2024
f7330b3
Merge branch 'main' into feat/nonmatching_output
adthrasher Jul 16, 2024
1b49c52
chore: update Gauntlet and Arena after merge
adthrasher Jul 16, 2024
9a3fa7b
chore: update document callback signature after merge
adthrasher Jul 16, 2024
95579df
chore: update rules syntax
adthrasher Jul 16, 2024
23ac418
chore: add lifetime
adthrasher Jul 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Arena.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@ permalink = "https://github.com/stjudecloud/workflows/blob/efdca837bc35fe5647de6

[[diagnostics]]
document = "stjudecloud/workflows:/tools/fq.wdl"
message = "fq.wdl:91:9: warning[NonmatchingOutput]: output `check` is missing from `meta` section in task `fqlint`"
message = "fq.wdl:91:9: warning[NonmatchingOutput]: output `check` is missing from `meta.outputs` section in task `fqlint`"
permalink = "https://github.com/stjudecloud/workflows/blob/efdca837bc35fe5647de6aa95989652a5a9648dc/tools/fq.wdl/#L91"

[[diagnostics]]
Expand Down Expand Up @@ -1332,7 +1332,7 @@ permalink = "https://github.com/stjudecloud/workflows/blob/efdca837bc35fe5647de6

[[diagnostics]]
document = "stjudecloud/workflows:/tools/ngsderive.wdl"
message = "ngsderive.wdl:133:9: warning[NonmatchingOutput]: output `instrument_string` is missing from `meta` section in task `instrument`"
message = "ngsderive.wdl:133:9: warning[NonmatchingOutput]: output `instrument_string` is missing from `meta.outputs` section in task `instrument`"
permalink = "https://github.com/stjudecloud/workflows/blob/efdca837bc35fe5647de6aa95989652a5a9648dc/tools/ngsderive.wdl/#L133"

[[diagnostics]]
Expand All @@ -1352,7 +1352,7 @@ permalink = "https://github.com/stjudecloud/workflows/blob/efdca837bc35fe5647de6

[[diagnostics]]
document = "stjudecloud/workflows:/tools/ngsderive.wdl"
message = "ngsderive.wdl:80:9: warning[NonmatchingOutput]: output `strandedness_string` is missing from `meta` section in task `strandedness`"
message = "ngsderive.wdl:80:9: warning[NonmatchingOutput]: output `strandedness_string` is missing from `meta.outputs` section in task `strandedness`"
permalink = "https://github.com/stjudecloud/workflows/blob/efdca837bc35fe5647de6aa95989652a5a9648dc/tools/ngsderive.wdl/#L80"

[[diagnostics]]
Expand Down Expand Up @@ -1382,7 +1382,7 @@ permalink = "https://github.com/stjudecloud/workflows/blob/efdca837bc35fe5647de6

[[diagnostics]]
document = "stjudecloud/workflows:/tools/picard.wdl"
message = "picard.wdl:982:9: warning[NonmatchingOutput]: output `interval_lists_scatter` is missing from `meta` section in task `scatter_interval_list`"
message = "picard.wdl:982:9: warning[NonmatchingOutput]: output `interval_lists_scatter` is missing from `meta.outputs` section in task `scatter_interval_list`"
permalink = "https://github.com/stjudecloud/workflows/blob/efdca837bc35fe5647de6aa95989652a5a9648dc/tools/picard.wdl/#L982"

[[diagnostics]]
Expand All @@ -1402,12 +1402,12 @@ permalink = "https://github.com/stjudecloud/workflows/blob/efdca837bc35fe5647de6

[[diagnostics]]
document = "stjudecloud/workflows:/tools/sambamba.wdl"
message = "sambamba.wdl:219:9: warning[NonmatchingOutput]: output `duplicate_marked_bam_index` is missing from `meta` section in task `markdup`"
message = "sambamba.wdl:219:9: warning[NonmatchingOutput]: output `duplicate_marked_bam_index` is missing from `meta.outputs` section in task `markdup`"
permalink = "https://github.com/stjudecloud/workflows/blob/efdca837bc35fe5647de6aa95989652a5a9648dc/tools/sambamba.wdl/#L219"

[[diagnostics]]
document = "stjudecloud/workflows:/tools/sambamba.wdl"
message = "sambamba.wdl:220:9: warning[NonmatchingOutput]: output `markdup_log` is missing from `meta` section in task `markdup`"
message = "sambamba.wdl:220:9: warning[NonmatchingOutput]: output `markdup_log` is missing from `meta.outputs` section in task `markdup`"
permalink = "https://github.com/stjudecloud/workflows/blob/efdca837bc35fe5647de6aa95989652a5a9648dc/tools/sambamba.wdl/#L220"

[[diagnostics]]
Expand Down Expand Up @@ -1462,7 +1462,7 @@ permalink = "https://github.com/stjudecloud/workflows/blob/efdca837bc35fe5647de6

[[diagnostics]]
document = "stjudecloud/workflows:/tools/util.wdl"
message = "util.wdl:136:9: warning[NonmatchingOutput]: output `split_strings` is missing from `meta` section in task `split_string`"
message = "util.wdl:136:9: warning[NonmatchingOutput]: output `split_strings` is missing from `meta.outputs` section in task `split_string`"
permalink = "https://github.com/stjudecloud/workflows/blob/efdca837bc35fe5647de6aa95989652a5a9648dc/tools/util.wdl/#L136"

[[diagnostics]]
Expand Down Expand Up @@ -1642,12 +1642,12 @@ permalink = "https://github.com/stjudecloud/workflows/blob/efdca837bc35fe5647de6

[[diagnostics]]
document = "stjudecloud/workflows:/workflows/qc/quality-check-standard.wdl"
message = "quality-check-standard.wdl:453:9: warning[NonmatchingOutput]: output `inferred_endedness` is missing from `meta` section in workflow `quality_check`"
message = "quality-check-standard.wdl:453:9: warning[NonmatchingOutput]: output `inferred_endedness` is missing from `meta.outputs` section in workflow `quality_check`"
permalink = "https://github.com/stjudecloud/workflows/blob/efdca837bc35fe5647de6aa95989652a5a9648dc/workflows/qc/quality-check-standard.wdl/#L453"

[[diagnostics]]
document = "stjudecloud/workflows:/workflows/qc/quality-check-standard.wdl"
message = "quality-check-standard.wdl:492:9: warning[NonmatchingOutput]: output `intermediate_files` is missing from `meta` section in workflow `quality_check`"
message = "quality-check-standard.wdl:492:9: warning[NonmatchingOutput]: output `intermediate_files` is missing from `meta.outputs` section in workflow `quality_check`"
permalink = "https://github.com/stjudecloud/workflows/blob/efdca837bc35fe5647de6aa95989652a5a9648dc/workflows/qc/quality-check-standard.wdl/#L492"

[[diagnostics]]
Expand Down
20 changes: 10 additions & 10 deletions Gauntlet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ commit_hash = "4e7fdfa7992dd1bf4c4721e77c81e4d7b8ecf4fe"

[repositories."broadinstitute/warp"]
identifier = "broadinstitute/warp"
commit_hash = "e52f2c1aabdb88b565c132e5587d05b91c4e6c0f"
commit_hash = "b8a753edd8e761a835164cc7b84f136c7fbe51d1"

[repositories."chanzuckerberg/czid-workflows"]
identifier = "chanzuckerberg/czid-workflows"
commit_hash = "b7c97a87d995a31d85bb6c8ee780fdf33d5bc176"
commit_hash = "ee513b4b7a79c5a8fe359c6bf6a6b15db33591ab"

[repositories."getwilds/ww-fastq-to-cram"]
identifier = "getwilds/ww-fastq-to-cram"
Expand All @@ -49,7 +49,7 @@ filters = ["/template/task-templates.wdl"]

[repositories."theiagen/public_health_bioinformatics"]
identifier = "theiagen/public_health_bioinformatics"
commit_hash = "59ee38708ffdfc5dbbdd2f0df3ab02064570447a"
commit_hash = "23552eaa4e151bc34745af3b90ff7b13154addd1"

[[diagnostics]]
document = "aws-samples/amazon-omics-tutorials:/example-workflows/gatk-best-practices/workflows/somatic-snps-and-indels/mutec2.wdl"
Expand Down Expand Up @@ -384,34 +384,34 @@ permalink = "https://github.com/broadinstitute/palantir-workflows/blob/4e7fdfa79
[[diagnostics]]
document = "broadinstitute/warp:/pipelines/skylab/scATAC/scATAC.wdl"
message = "scATAC.wdl:203:9: error: duplicate key `cpu` in runtime section"
permalink = "https://github.com/broadinstitute/warp/blob/e52f2c1aabdb88b565c132e5587d05b91c4e6c0f/pipelines/skylab/scATAC/scATAC.wdl/#L203"
permalink = "https://github.com/broadinstitute/warp/blob/b8a753edd8e761a835164cc7b84f136c7fbe51d1/pipelines/skylab/scATAC/scATAC.wdl/#L203"

[[diagnostics]]
document = "broadinstitute/warp:/tasks/broad/GermlineVariantDiscovery.wdl"
message = "GermlineVariantDiscovery.wdl:137:32: error: expected string, but found integer"
permalink = "https://github.com/broadinstitute/warp/blob/e52f2c1aabdb88b565c132e5587d05b91c4e6c0f/tasks/broad/GermlineVariantDiscovery.wdl/#L137"
permalink = "https://github.com/broadinstitute/warp/blob/b8a753edd8e761a835164cc7b84f136c7fbe51d1/tasks/broad/GermlineVariantDiscovery.wdl/#L137"

[[diagnostics]]
document = "broadinstitute/warp:/tasks/broad/GermlineVariantDiscovery.wdl"
message = "GermlineVariantDiscovery.wdl:65:32: error: expected string, but found integer"
permalink = "https://github.com/broadinstitute/warp/blob/e52f2c1aabdb88b565c132e5587d05b91c4e6c0f/tasks/broad/GermlineVariantDiscovery.wdl/#L65"
permalink = "https://github.com/broadinstitute/warp/blob/b8a753edd8e761a835164cc7b84f136c7fbe51d1/tasks/broad/GermlineVariantDiscovery.wdl/#L65"

[[diagnostics]]
document = "broadinstitute/warp:/tasks/broad/UltimaGenomicsWholeGenomeGermlineTasks.wdl"
message = "UltimaGenomicsWholeGenomeGermlineTasks.wdl:814:27: error: expected string, but found integer"
permalink = "https://github.com/broadinstitute/warp/blob/e52f2c1aabdb88b565c132e5587d05b91c4e6c0f/tasks/broad/UltimaGenomicsWholeGenomeGermlineTasks.wdl/#L814"
permalink = "https://github.com/broadinstitute/warp/blob/b8a753edd8e761a835164cc7b84f136c7fbe51d1/tasks/broad/UltimaGenomicsWholeGenomeGermlineTasks.wdl/#L814"

[[diagnostics]]
document = "broadinstitute/warp:/tasks/broad/UltimaGenomicsWholeGenomeGermlineTasks.wdl"
message = "UltimaGenomicsWholeGenomeGermlineTasks.wdl:866:27: error: expected string, but found integer"
permalink = "https://github.com/broadinstitute/warp/blob/e52f2c1aabdb88b565c132e5587d05b91c4e6c0f/tasks/broad/UltimaGenomicsWholeGenomeGermlineTasks.wdl/#L866"
permalink = "https://github.com/broadinstitute/warp/blob/b8a753edd8e761a835164cc7b84f136c7fbe51d1/tasks/broad/UltimaGenomicsWholeGenomeGermlineTasks.wdl/#L866"

[[diagnostics]]
document = "broadinstitute/warp:/tests/cemba/pr/CheckCembaOutputs.wdl"
message = "CheckCembaOutputs.wdl:1:1: error: a WDL document must start with a version statement"
permalink = "https://github.com/broadinstitute/warp/blob/e52f2c1aabdb88b565c132e5587d05b91c4e6c0f/tests/cemba/pr/CheckCembaOutputs.wdl/#L1"
permalink = "https://github.com/broadinstitute/warp/blob/b8a753edd8e761a835164cc7b84f136c7fbe51d1/tests/cemba/pr/CheckCembaOutputs.wdl/#L1"

[[diagnostics]]
document = "chanzuckerberg/czid-workflows:/workflows/index-generation/index-generation.wdl"
message = "index-generation.wdl:1:9: error: unsupported WDL version `development`"
permalink = "https://github.com/chanzuckerberg/czid-workflows/blob/b7c97a87d995a31d85bb6c8ee780fdf33d5bc176/workflows/index-generation/index-generation.wdl/#L1"
permalink = "https://github.com/chanzuckerberg/czid-workflows/blob/ee513b4b7a79c5a8fe359c6bf6a6b15db33591ab/workflows/index-generation/index-generation.wdl/#L1"
2 changes: 1 addition & 1 deletion wdl-ast/src/v1/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ impl AstNode for MetadataSection {

/// Represents a metadata object item.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct MetadataObjectItem(SyntaxNode);
pub struct MetadataObjectItem(pub(crate) SyntaxNode);

impl MetadataObjectItem {
/// Gets the name of the item.
Expand Down
11 changes: 11 additions & 0 deletions wdl-ast/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,17 @@ impl Visitor for Validator {
}
}

fn metadata_object_item(
&mut self,
state: &mut Self::State,
reason: VisitReason,
item: &v1::MetadataObjectItem,
) {
for visitor in self.visitors.iter_mut() {
visitor.metadata_object_item(state, reason, item);
}
}

fn unbound_decl(
&mut self,
state: &mut Self::State,
Expand Down
20 changes: 17 additions & 3 deletions wdl-ast/src/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use crate::v1::Expr;
use crate::v1::ImportStatement;
use crate::v1::InputSection;
use crate::v1::MetadataObject;
use crate::v1::MetadataObjectItem;
use crate::v1::MetadataSection;
use crate::v1::OutputSection;
use crate::v1::ParameterMetadataSection;
Expand Down Expand Up @@ -185,6 +186,15 @@ pub trait Visitor: Send + Sync {
) {
}

/// Visits a metadata object item in a metadata object.
fn metadata_object_item(
&mut self,
state: &mut Self::State,
reason: VisitReason,
item: &MetadataObjectItem,
) {
}

/// Visits an unbound declaration node.
fn unbound_decl(&mut self, state: &mut Self::State, reason: VisitReason, decl: &UnboundDecl) {}

Expand Down Expand Up @@ -314,9 +324,13 @@ pub(crate) fn visit<V: Visitor>(root: &SyntaxNode, state: &mut V::State, visitor
reason,
&MetadataObject(element.into_node().unwrap()),
),
SyntaxKind::MetadataObjectItemNode
| SyntaxKind::MetadataArrayNode
| SyntaxKind::LiteralNullNode => {
SyntaxKind::MetadataObjectItemNode => visitor.metadata_object_item(
state,
reason,
&MetadataObjectItem(element.into_node().unwrap()),
),

SyntaxKind::MetadataArrayNode | SyntaxKind::LiteralNullNode => {
// Skip these nodes as they're part of a metadata section
}
k if Expr::can_cast(k) => visitor.expr(
Expand Down
2 changes: 1 addition & 1 deletion wdl-lint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub fn rules() -> Vec<Box<dyn Rule>> {
Box::new(rules::SectionOrderingRule),
Box::new(rules::DeprecatedObjectRule),
Box::new(rules::DescriptionMissingRule),
Box::new(rules::NonmatchingOutputRule),
Box::new(rules::NonmatchingOutputRule::default()),
adthrasher marked this conversation as resolved.
Show resolved Hide resolved
];

// Ensure all the rule ids are unique and pascal case
Expand Down
Loading
Loading