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 codespell to validate spelling mistakes in code. #4817

Merged
merged 1 commit into from
Jan 13, 2020

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented Jan 8, 2020

Fix all errors found by codespell

Signed-off-by: Daniel J Walsh [email protected]

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhatdan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M labels Jan 8, 2020
@@ -49,11 +49,11 @@ func pruneContainersCmd(c *cliconfig.PruneContainersValues) error {
reader := bufio.NewReader(os.Stdin)
fmt.Printf(`WARNING! This will remove all stopped containers.
Are you sure you want to continue? [y/N] `)
ans, err := reader.ReadString('\n')
answer, err := reader.ReadString('\n')
Copy link
Member

Choose a reason for hiding this comment

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

I really don't like this. Can we restrict to comments only? I don't want a spell-checker telling me what my variable names can and cannot be.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, and we can tell the codespeller to ignore certain names, in this case I actually liked the change, since I was not crazy about ans.

Makefile Outdated
@@ -530,7 +534,7 @@ validate.completions: completions/bash/podman
. completions/bash/podman
if [ -x /bin/zsh ]; then /bin/zsh completions/zsh/_podman; fi

validate: gofmt .gitvalidation validate.completions golangci-lint man-page-check
validate: gofmt .gitvalidation validate.completions golangci-lint man-page-check codespell
Copy link
Member

@TomSweeneyRedHat TomSweeneyRedHat Jan 8, 2020

Choose a reason for hiding this comment

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

I'm just concerned about codespell being a bit overzealous and keeping the build from happening. Will it just ping a warning or stop the submit from going forward?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we should have this on by default, and see if it causes issues, once I get it into a good state. I think this would help us keep this clean.

Copy link
Member

Choose a reason for hiding this comment

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

Off the bat, this will run first from the gate task here. Adding things to the container image is easy, see contrib/gate/Dockerfile. Do that in a separate PR, and once merged, quay will automatically build the image (can be confirmed by logging in and checking it on quay). Then, re-running the jobs here will start using the new image.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have disabled it by default for now, so we can get this PR merged, and then we can figure out how to get the CI system to gate on it in a future PR.

@@ -1365,7 +1365,7 @@ func (c *Container) getHosts() string {
}

// generatePasswd generates a container specific passwd file,
// iff g.config.User is a number
// if g.config.User is a number
Copy link
Member

Choose a reason for hiding this comment

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

This is definitely wrong - iff is accepted terminology

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

AFAIK, codespell is too strict in some cases. golangci-lint does spellchecks already but less strict. Maybe we can run it periodically but not make it part of the CI?

@@ -789,7 +789,7 @@ func (config *CreateConfig) getTmpfsMounts() (map[string]spec.Mount, error) {
return m, nil
}

// AddContainerInitBinary adds the init binary specified by path iff the
// AddContainerInitBinary adds the init binary specified by path if the
Copy link
Member

Choose a reason for hiding this comment

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

Again, iff is valid

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I will revert and make iff valid.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

if err != nil {
return errors.Wrapf(err, "error reading input")
}
if strings.ToLower(ans)[0] != 'y' {
if strings.ToLower(answer)[0] != 'y' {
Copy link
Member

Choose a reason for hiding this comment

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

This right here is an example of a change that I don't think should keep a build from completing. 'answer' is better for sure, but not a stopper in my book.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is better.

@@ -19,7 +19,7 @@
%endif

# %if ! 0% {?gobuild:1}
%define gobuild(o:) go build -tags="$BUILDTAGS" -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n')" -a -v -x %{?**};
%define gobuild(o:) go build -tags="$BUILDTAGS" -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|of -An -tx1|tr -d ' \\n')" -a -v -x %{?**};
Copy link
Member

Choose a reason for hiding this comment

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

is this a valid change?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, I thought I reverted, this one.

Copy link
Member

Choose a reason for hiding this comment

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

Oops, looks like it got merged.

@@ -52,7 +52,7 @@ To view a container's logs:
```
podman logs -t b3f2436bdb978c1d33b1387afb5d7ba7e3243ed2ce908db431ac0069da86cb45

2017/08/07 10:16:21 Seeked /var/log/crio/pods/eb296bd56fab164d4d3cc46e5776b54414af3bf543d138746b25832c816b933b/c49f49788da14f776b7aa93fb97a2a71f9912f4e5a3e30397fca7dfe0ee0367b.log - &{Offset:0 Whence:0}
2017/08/07 10:16:21 Sought /var/log/crio/pods/eb296bd56fab164d4d3cc46e5776b54414af3bf543d138746b25832c816b933b/c49f49788da14f776b7aa93fb97a2a71f9912f4e5a3e30397fca7dfe0ee0367b.log - &{Offset:0 Whence:0}
Copy link
Member

Choose a reason for hiding this comment

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

the log message is generated by: https://github.com/hpcloud/tail/blob/master/tail.go#L244

Should we replace it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope should be reverted.

@@ -52,7 +52,7 @@ To view a container's logs:
```
podman logs -t b3f2436bdb978c1d33b1387afb5d7ba7e3243ed2ce908db431ac0069da86cb45

2017/08/07 10:16:21 Seeked /var/log/crio/pods/eb296bd56fab164d4d3cc46e5776b54414af3bf543d138746b25832c816b933b/c49f49788da14f776b7aa93fb97a2a71f9912f4e5a3e30397fca7dfe0ee0367b.log - &{Offset:0 Whence:0}
2017/08/07 10:16:21 Sought /var/log/crio/pods/eb296bd56fab164d4d3cc46e5776b54414af3bf543d138746b25832c816b933b/c49f49788da14f776b7aa93fb97a2a71f9912f4e5a3e30397fca7dfe0ee0367b.log - &{Offset:0 Whence:0}
Copy link
Member

Choose a reason for hiding this comment

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

This probably should not change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope these should be eliminated

@rhatdan
Copy link
Member Author

rhatdan commented Jan 8, 2020

@cevich Do I need to rebuild AMI to get codespell installed?

@cevich
Copy link
Member

cevich commented Jan 8, 2020

to get codespell installed?

Possibly, depends on how it's being called. Installing at runtime is possible if you can find all the places it's required, but will slow down testing for everyone and reduce automation reliability slightly. Let me take a peek at what you have here, then I can make better suggestions...

@cevich
Copy link
Member

cevich commented Jan 8, 2020

...https://github.com/containers/libpod/pull/4817/files#r364406947 I don't recall if we run 'make validate' from anywhere else (or it gets called by a dependency). Getting past the gate job should be easy, then we'll know if it breaks elsewhere. If so, I can help deal with that.

Fix all errors found by codespell

Signed-off-by: Daniel J Walsh <[email protected]>
@rhatdan
Copy link
Member Author

rhatdan commented Jan 13, 2020

@TomSweeneyRedHat @mheon @vrothberg Since codespell is no longer blocking can we get his merged?

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@TomSweeneyRedHat TomSweeneyRedHat left a comment

Choose a reason for hiding this comment

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

LGTM
FWIW, I too like the ans to answer variable name change, I just didn't want changes like that holding up a PR in test.

@mheon
Copy link
Member

mheon commented Jan 13, 2020

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 13, 2020
@openshift-merge-robot openshift-merge-robot merged commit e83a1b8 into containers:master Jan 13, 2020
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants