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 support for a custom success error message. #72

Merged

Conversation

platinummonkey
Copy link
Contributor

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Feature

What is the current behavior? (You can also link to an open issue here)
Currently the success message is statically set to "No violations found. Stay woke \u270a"

What is the new behavior (if this is a feature change)?
This allows users to personalize their response when no violations are found using the config file via the optional success_exit_message.

Does this PR introduce a breaking change? (What changes might users need to make due to this PR?)
Non-breaking change.

Other information:

This allows users to personalize their response when no violations are found.
@codecov
Copy link

codecov bot commented May 5, 2021

Codecov Report

Merging #72 (086c355) into main (576b42a) will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #72      +/-   ##
==========================================
+ Coverage   95.48%   95.52%   +0.03%     
==========================================
  Files          21       21              
  Lines         465      469       +4     
==========================================
+ Hits          444      448       +4     
  Misses         12       12              
  Partials        9        9              
Impacted Files Coverage Δ
cmd/root.go 84.48% <100.00%> (+0.27%) ⬆️
pkg/config/config.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 576b42a...086c355. Read the comment docs.

Copy link
Member

@caitlinelfring caitlinelfring left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! I think this is a great addition, but I'm curious what the use case is for making this customizable?

cmd/root.go Outdated
@@ -112,7 +112,11 @@ func rootRunE(cmd *cobra.Command, args []string) error {
}

if violations == 0 {
fmt.Fprintln(output.Stdout, "No violations found. Stay woke \u270a")
successExitMessage := "No violations found. Stay woke \u270a"
Copy link
Member

Choose a reason for hiding this comment

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

It might be worth utilizing viper's defaults for this https://github.com/spf13/viper#establishing-defaults. This would allow you to support the case where one may wish to set successExitMessage to an empty string. I believe initConfig would be a good place for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like config package loads directly from yaml.Unmarshal in loadConfig ignoring any viper configuration. where rootRunE calls cfg, err := config.NewConfig(viper.ConfigFileUsed()) which is only a path reference.

Copy link
Member

Choose a reason for hiding this comment

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

Ah yes, that's right. viper doesn't fully manage the config file yet, I had to restrict it to yaml because I haven't had the chance to port the unmarshaling over yet.

@@ -74,6 +77,20 @@ func TestRunE(t *testing.T) {
expected := "No violations found. Stay woke \u270a\n"
assert.Equal(t, expected, got)
})

t.Run("no violations found with custom message", func(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Would you consider a test case for setting the custom success message to an empty string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added this to config_test.go 👍

@platinummonkey
Copy link
Contributor Author

Thanks for the contribution! I think this is a great addition, but I'm curious what the use case is for making this customizable?

While the tool focuses on inclusivity (great!) it could also be used for additional language linting. Highlighting common grammatical mistakes, or used to correct common mispellings of internal service names or to promote an end to service name that is longer longer available.

The other reason being while trying to adopt this tool, some feedback that the literal word woke in the context felt passive aggressive - I understand this is highly subjective. Where Thanks! Everything looks great! - while a contrived generic example is less likely to offend someone.

refactor config so this can be set to be a literal empty string as well
@caitlinelfring caitlinelfring merged commit f017562 into get-woke:main May 5, 2021
@caitlinelfring
Copy link
Member

@platinummonkey this change has been released in v0.8.0. Thanks again for the contribution!

@platinummonkey platinummonkey deleted the configurable-exit-message branch May 6, 2021 16:18
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