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

ci: Configure crate-ci/typos and auto fix what I can #1551

Merged
merged 2 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ or `make help` for a list of available commands with descriptions.
- Avoid the passive voice ("When a tag is provided, access is granted") and use the active voice ("Entering a tag provides access")
- Be helpful when users have to enter a input that is from a list of possible values. Give examples, list the possible values inline (if the list is relatively short), or point them to a command that can list the possible values for them.

## Spell Check

`doctl` is setup to use the code aware spell checker called [typos](https://github.com/crate-ci/typos) to keep an eye on any spelling mistakes.

To install your own copy,follow the instructions on the [typos readme](https://github.com/crate-ci/typos?tab=readme-ov-file#install), and then run the `typos` binary

### Go environment

Expand Down
16 changes: 16 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[files]
extend-exclude = [
"vendor/**",
"go.mod"
]

[default.extend-identifiers]
vas = "vas"
splitted = "splitted"

[default.extend-words]
# Its not perfect at hashes yet
cace = "cace"
Wqs = "Wqs"
# example and exmaple as two domain examples
exmaple = "exmaple"
4 changes: 2 additions & 2 deletions args.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,8 @@ const (
ArgDatabaseTopicMaxCompactionLagMS = "max-compaction-lag-ms"
// ArgDatabaseTopicMaxMessageBytes is the maximum size, in bytes, of the largest record batch that can be sent to the server
ArgDatabaseTopicMaxMessageBytes = "max-message-bytes"
// ArgDatabaseTopicMesssageDownConversionEnable determines whether brokers should convert messages for consumers expecting older message formats
ArgDatabaseTopicMesssageDownConversionEnable = "message-down-conversion-enable"
// ArgDatabaseTopicMessageDownConversionEnable determines whether brokers should convert messages for consumers expecting older message formats
ArgDatabaseTopicMessageDownConversionEnable = "message-down-conversion-enable"
Copy link
Member

Choose a reason for hiding this comment

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

As this is a "code aware" spell checker, any chance you happen to know if there is a way to exclude existing exported vars/consts? That's not really an issue for doctl itself, but if we were to bring this into say godo, we'd want to avoid breaking changes.

Copy link
Member Author

Choose a reason for hiding this comment

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

so best i've found in the past was default.extend-identifiers in the config, but nothing automated
I believe typos also has a cli flag for listing all the identifiers it finds

that being said, fixing the spelling is an easy breaking change to handle for end users, its not like they have to figure out how to rewrite code because a function no longer exists.

// ArgDatabaseTopicMessageFormatVersion is the version used by the broker to append messages to the kafka topic logs
ArgDatabaseTopicMessageFormatVersion = "message-format-version"
// ArgDatabaseTopicMessageTimestampType is the timestamp used for messages
Expand Down
2 changes: 1 addition & 1 deletion commands/command_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func (c *CmdConfig) Display(d displayers.Displayable) error {
return dc.Display()
}

// An urner implements the URN method, wihich returns a valid uniform resource
// An urner implements the URN method, which returns a valid uniform resource
// name.
type urner interface {
URN() string
Expand Down
4 changes: 2 additions & 2 deletions commands/databases.go
Original file line number Diff line number Diff line change
Expand Up @@ -1791,7 +1791,7 @@ func getDatabaseTopicConfigArgs(c *CmdConfig) *godo.TopicConfig {
res.MaxMessageBytes = &i
}
}
bVal, err := c.Doit.GetBoolPtr(c.NS, doctl.ArgDatabaseTopicMesssageDownConversionEnable)
bVal, err := c.Doit.GetBoolPtr(c.NS, doctl.ArgDatabaseTopicMessageDownConversionEnable)
if err == nil && bVal != nil {
res.MessageDownConversionEnable = bVal
}
Expand Down Expand Up @@ -1936,7 +1936,7 @@ This command lists the following details for each partition of a given topic in
"Specifies the maximum time (in ms) that a message will remain uncompacted. This is only applicable if the logs have compaction enabled")
AddStringFlag(c, doctl.ArgDatabaseTopicMaxMessageBytes, "", "",
"Specifies the largest record batch (in bytes) that can be sent to the server. This is calculated after compression, if compression is enabled")
AddBoolFlag(c, doctl.ArgDatabaseTopicMesssageDownConversionEnable, "", true,
AddBoolFlag(c, doctl.ArgDatabaseTopicMessageDownConversionEnable, "", true,
"Specifies whether down-conversion of message formats is enabled to satisfy consumer requests")
AddStringFlag(c, doctl.ArgDatabaseTopicMessageFormatVersion, "", "",
"Specifies the message format version used by the broker to append messages to the logs. By setting a format version, all existing messages on disk must be smaller or equal to the specified version")
Expand Down
3 changes: 2 additions & 1 deletion commands/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ import (
"strings"

"github.com/apache/openwhisk-client-go/whisk"
"github.com/spf13/cobra"

"github.com/digitalocean/doctl"
"github.com/digitalocean/doctl/commands/charm/template"
"github.com/digitalocean/doctl/commands/displayers"
"github.com/digitalocean/doctl/do"
"github.com/spf13/cobra"
)

// Functions generates the serverless 'functions' subtree for addition to the doctl command
Expand Down
2 changes: 1 addition & 1 deletion commands/serverless_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ func TestServerlessInit(t *testing.T) {
}

sawOverwrite := false
// Grab the overrideable commands so they can be mocked
// Grab the overridable commands so they can be mocked
writeAFile = func(path string, contents []byte) error {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion do/serverless.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type OutputNamespace struct {
}

// FunctionParameter is the type of a parameter in the response body of action.get. We do our
// own JSON unmarshaling of these because the go OpenWhisk client doesn't include the "init" and
// own JSON unmarshalling of these because the go OpenWhisk client doesn't include the "init" and
// "encryption" members, of which at least "init" is needed.
type FunctionParameter struct {
Key string `json:"key"`
Expand Down
2 changes: 1 addition & 1 deletion integration/droplet_neighbors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ var _ = suite("compute/droplet/neighbors", func(t *testing.T, when spec.G, it sp
})

when("asking for particular headers", func() {
it("only lists thoses headers", func() {
it("only lists those headers", func() {
cmd := exec.Command(builtBinaryPath,
"compute",
"droplet",
Expand Down
2 changes: 1 addition & 1 deletion scripts/version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Options:
-i, --image snap image version
-b, --branch branch only
-c, --commit commit only
--snap, returns the version formated for a snap release
--snap, returns the version formatted for a snap release
"

semver() {
Expand Down
Loading