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

Add severity option for validators #131

Merged
merged 2 commits into from
Mar 18, 2024
Merged

Add severity option for validators #131

merged 2 commits into from
Mar 18, 2024

Conversation

hpmellema
Copy link
Contributor

Background

Adds a property to set the severity of validators for the validate and build tasks.

The default severity for the build task remains WARNING while the default for the jarValidate task is updated to ERROR. This prevents the double-printing of warning events during the build so that by default the jarValidate task only prints validation events that would have caused it to fail.

Note: not all smithy-cli commands have a severity option.

Testing

Executed a build with and without this change and confirmed the

> Task :service:smithyFormat
Running smithy format

> Task :service:smithyBuild
Running smithy build

──  WARNING  ──────────────────────────────────────────────────────────── DocUrl
Shape: com.example.cafe.service#Order
File:  /Users/hpm/smithy-gradle-tutorial/service/model/service.smithy:25:1

24| @externalDocumentation(wikipedia: "https://en.wikipedia.org/wiki/Order")
25| resource Order {
  | ^

External url `https://en.wikipedia.org/wiki/Order` is invalid.


──  WARNING  ────────────────────────── HttpMethodSemantics.MissingReadonlyTrait
Shape: com.example.cafe.common#dummy
File:  /Users/hpm/smithy-gradle-tutorial/lib/build/libs/lib.jar!/META-INF/smithy/common.smithy:25:1

25| @http(code: 200, method: "GET", uri: "/yay")
  | ^
26| operation dummy {}

This operation uses the `GET` method in the `http` trait, but is not marked with
the readonly trait

SUCCESS: Validated 234 shapes (WARNING: 2)

Validated model, now starting projections...

──  source  ────────────────────────────────────────────────────────────────────
Completed projection source (234): /Users/hpm/smithy-gradle-tutorial/service/build/smithyprojections/service/source

Summary: Smithy built 1 projection(s), 3 plugin(s), and 4 artifacts

> Task :service:smithyJarValidate
Running smithy validate

──  WARNING  ────────────────────────── HttpMethodSemantics.MissingReadonlyTrait
Shape: com.example.cafe.common#dummy
File:  /Users/hpm/smithy-gradle-tutorial/lib/build/libs/lib.jar!/META-INF/smithy/common.smithy:25:1

25| @http(code: 200, method: "GET", uri: "/yay")
  | ^
26| operation dummy {}

This operation uses the `GET` method in the `http` trait, but is not marked with
the readonly trait


──  WARNING  ──────────────────────────────────────────────────────────── DocUrl
Shape: com.example.cafe.service#Order
File:  /Users/hpm/smithy-gradle-tutorial/service/build/libs/service.jar!/META-INF/smithy/service.smithy:25:1

24| @externalDocumentation(wikipedia: "https://en.wikipedia.org/wiki/Order")
25| resource Order {
  | ^

External url `https://en.wikipedia.org/wiki/Order` is invalid.

SUCCESS: Validated 234 shapes (WARNING: 2)


BUILD SUCCESSFUL in 4s
17 actionable tasks: 17 executed

After this change:

> Task :service:smithyFormat
Running smithy format

> Task :service:smithyBuild
Running smithy build

──  WARNING  ──────────────────────────────────────────────────────────── DocUrl
Shape: com.example.cafe.service#Order
File:  /Users/hpm/smithy-gradle-tutorial/service/model/service.smithy:25:1

24| @externalDocumentation(wikipedia: "https://en.wikipedia.org/wiki/Order")
25| resource Order {
  | ^

External url `https://en.wikipedia.org/wiki/Order` is invalid.


──  WARNING  ────────────────────────── HttpMethodSemantics.MissingReadonlyTrait
Shape: com.example.cafe.common#dummy
File:  /Users/hpm/smithy-gradle-tutorial/lib/build/libs/lib.jar!/META-INF/smithy/common.smithy:25:1

25| @http(code: 200, method: "GET", uri: "/yay")
  | ^
26| operation dummy {}

This operation uses the `GET` method in the `http` trait, but is not marked with
the readonly trait

SUCCESS: Validated 234 shapes (WARNING: 2)

Validated model, now starting projections...

──  source  ────────────────────────────────────────────────────────────────────
Completed projection source (234): /Users/hpm/smithy-gradle-tutorial/service/build/smithyprojections/service/source

Summary: Smithy built 1 projection(s), 3 plugin(s), and 4 artifacts

> Task :service:smithyJarValidate
Running smithy validate
SUCCESS: Validated 234 shapes (WARNING: 2)


BUILD SUCCESSFUL in 15s
17 actionable tasks: 17 executed

Links

  • Links to additional context, if necessary
  • Issue #, if applicable (see here for a list of keywords to use for linking issues)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@hpmellema hpmellema requested a review from a team as a code owner March 18, 2024 18:07
@hpmellema hpmellema merged commit 8a4d35b into main Mar 18, 2024
4 checks passed
@hpmellema hpmellema deleted the add-severity-option branch March 18, 2024 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants