Skip to content

Commit

Permalink
Refactor rename validation rule from missing to required
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed Jun 16, 2024
1 parent 9b65f9f commit 20254a2
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions server/gx-workflow-ls-format2/src/profiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
BasicCommonValidationProfile,
IWCCommonValidationProfile,
} from "@gxwf/server-common/src/providers/validation/profiles";
import { MissingPropertyValidationRule } from "@gxwf/server-common/src/providers/validation/rules";
import { RequiredPropertyValidationRule } from "@gxwf/server-common/src/providers/validation/rules";

/**
* Defines the minimal set of validation rules for gxformat2 Galaxy workflows.
Expand All @@ -28,7 +28,7 @@ export class GxFormat2IWCValidationProfile extends IWCCommonValidationProfile {
protected static readonly RULES = new Set([
...super.RULES,
...GxFormat2BasicValidationProfile.RULES,
new MissingPropertyValidationRule(
new RequiredPropertyValidationRule(
"doc",
true,
DiagnosticSeverity.Error,
Expand Down
4 changes: 2 additions & 2 deletions server/gx-workflow-ls-native/src/profiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
BasicCommonValidationProfile,
IWCCommonValidationProfile,
} from "@gxwf/server-common/src/providers/validation/profiles";
import { MissingPropertyValidationRule } from "@gxwf/server-common/src/providers/validation/rules";
import { RequiredPropertyValidationRule } from "@gxwf/server-common/src/providers/validation/rules";
import { WorkflowOutputLabelValidationRule } from "./validation/rules/WorkflowOutputLabelValidationRule";

/**
Expand All @@ -29,7 +29,7 @@ export class NativeIWCValidationProfile extends IWCCommonValidationProfile {
protected static readonly RULES = new Set([
...super.RULES,
...NativeBasicValidationProfile.RULES,
new MissingPropertyValidationRule(
new RequiredPropertyValidationRule(
"annotation",
true,
DiagnosticSeverity.Error,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DiagnosticSeverity, ValidationRule } from "@gxwf/server-common/src/languageTypes";
import { MissingPropertyValidationRule } from "@gxwf/server-common/src/providers/validation/rules";
import { RequiredPropertyValidationRule } from "@gxwf/server-common/src/providers/validation/rules";
import { WorkflowOutputLabelValidationRule } from "../../src/validation/rules/WorkflowOutputLabelValidationRule";
import { createNativeWorkflowDocument } from "../testHelpers";
import { TestWorkflowProvider } from "../testWorkflowProvider";
Expand Down Expand Up @@ -46,7 +46,7 @@ describe("Custom Validation Rules", () => {

describe("MissingPropertyValidation Rule", () => {
beforeAll(() => {
rule = new MissingPropertyValidationRule("release");
rule = new RequiredPropertyValidationRule("release");
});

it("should not provide diagnostics when the property is present", async () => {
Expand Down Expand Up @@ -83,7 +83,7 @@ describe("Custom Validation Rules", () => {
});

it("should provide warning diagnostics when the property is missing and severity is set to warning", async () => {
rule = new MissingPropertyValidationRule("release", true, DiagnosticSeverity.Warning);
rule = new RequiredPropertyValidationRule("release", true, DiagnosticSeverity.Warning);
const wfContents = `{
"a_galaxy_workflow": "true",
}`;
Expand All @@ -95,7 +95,7 @@ describe("Custom Validation Rules", () => {
});

it("should display a custom message when provided", async () => {
rule = new MissingPropertyValidationRule("release", true, DiagnosticSeverity.Warning, "Custom message");
rule = new RequiredPropertyValidationRule("release", true, DiagnosticSeverity.Warning, "Custom message");
const wfContents = `{
"a_galaxy_workflow": "true",
}`;
Expand All @@ -108,7 +108,7 @@ describe("Custom Validation Rules", () => {

describe("when valueRequired is false", () => {
beforeAll(() => {
rule = new MissingPropertyValidationRule("release", false);
rule = new RequiredPropertyValidationRule("release", false);
});

it("should not provide diagnostics when the property is present", async () => {
Expand Down Expand Up @@ -145,7 +145,7 @@ describe("Custom Validation Rules", () => {

describe("when the property is an array", () => {
beforeAll(() => {
rule = new MissingPropertyValidationRule("creator");
rule = new RequiredPropertyValidationRule("creator");
});

it("should not provide diagnostics when the property has a value", async () => {
Expand Down Expand Up @@ -173,7 +173,7 @@ describe("Custom Validation Rules", () => {

describe("when the property is an object", () => {
beforeAll(() => {
rule = new MissingPropertyValidationRule("steps");
rule = new RequiredPropertyValidationRule("steps");
});

it("should not provide diagnostics when the property has a value", async () => {
Expand Down Expand Up @@ -201,7 +201,7 @@ describe("Custom Validation Rules", () => {

describe("when the property is nested", () => {
beforeAll(() => {
rule = new MissingPropertyValidationRule("steps/0/tool_id");
rule = new RequiredPropertyValidationRule("steps/0/tool_id");
});

it("should not provide diagnostics when the property has a value", async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DiagnosticSeverity, ValidationProfile, ValidationRule } from "../../languageTypes";
import { MissingPropertyValidationRule, StepExportErrorValidationRule, TestToolshedValidationRule } from "./rules";
import { RequiredPropertyValidationRule, StepExportErrorValidationRule, TestToolshedValidationRule } from "./rules";

/**
* The *NoOp* validation profile.
Expand Down Expand Up @@ -38,19 +38,19 @@ export class IWCCommonValidationProfile implements ValidationProfile {
public readonly name: string = "IWC Best Practices";

protected static readonly RULES: Set<ValidationRule> = new Set([
new MissingPropertyValidationRule(
new RequiredPropertyValidationRule(
"release",
true,
DiagnosticSeverity.Error,
"The workflow must have a release version."
),
new MissingPropertyValidationRule(
new RequiredPropertyValidationRule(
"creator",
true,
DiagnosticSeverity.Error,
"The workflow does not specify a creator."
),
new MissingPropertyValidationRule(
new RequiredPropertyValidationRule(
"license",
true,
DiagnosticSeverity.Error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { DocumentContext, ValidationRule } from "../../../languageTypes";
* property is an object or an array, the rule will also check that it has at
* least one property or item.
*/
export class MissingPropertyValidationRule implements ValidationRule {
export class RequiredPropertyValidationRule implements ValidationRule {
constructor(
private nodePath: string,
private valueRequired: boolean = true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MissingPropertyValidationRule } from "./MissingPropertyValidation";
import { RequiredPropertyValidationRule } from "./MissingPropertyValidation";
import { StepExportErrorValidationRule } from "./StepErrorValidationRule";
import { TestToolshedValidationRule } from "./TestToolShedValidationRule";

export { MissingPropertyValidationRule, StepExportErrorValidationRule, TestToolshedValidationRule };
export { RequiredPropertyValidationRule, StepExportErrorValidationRule, TestToolshedValidationRule };
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
BasicCommonValidationProfile,
IWCCommonValidationProfile,
} from "@gxwf/server-common/src/providers/validation/profiles";
import { MissingPropertyValidationRule } from "@gxwf/server-common/src/providers/validation/rules";
import { RequiredPropertyValidationRule } from "@gxwf/server-common/src/providers/validation/rules";
import { WorkflowInputsValidationRule } from "./validation/rules/WorkflowInputsValidationRule";
import { WorkflowOutputsValidationRule } from "./validation/rules/WorkflowOutputsValidationRule";

Expand All @@ -30,13 +30,13 @@ export class TestDocumentBasicValidationProfile extends BasicCommonValidationPro
*/
export class TestDocumentIWCValidationProfile extends IWCCommonValidationProfile {
protected static readonly RULES = new Set([
...super.RULES,
...TestDocumentBasicValidationProfile.RULES,
new MissingPropertyValidationRule(
// TODO: This rule needs to be updated to check for the presence of the `doc` property in each test.
new RequiredPropertyValidationRule(
"doc",
true,
DiagnosticSeverity.Error,
"The workflow is not documented. Documenting workflows helps users understand the purpose of the workflow."
"The workflow test is not documented. Documenting workflows helps users understand the purpose of the workflow."
),
// Add more custom rules specific to native workflows here...
]);
Expand Down

0 comments on commit 20254a2

Please sign in to comment.