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

Don't require pointer to binding #2834

Merged
merged 3 commits into from
Jun 18, 2020

Conversation

bobcatfish
Copy link
Collaborator

Changes

Seems like bumping the golangci version
(tektoncd/plumbing#430) revealed some new
linting issues.

Pointers to items being ranged over are reused, so if this pointer is
stored anywhere and used later, it can lead to bugs.

I didn't see any reason why this needed to be a pointer so passing
around the value instead.

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • [n/a] Includes tests (if functionality changed/added)
  • [n/a] Includes docs (if user facing)
  • Commit messages follow commit message best practices
  • [n/a] Release notes block has been filled in or deleted (only if no user facing changes)

See the contribution guide for more details.

Double check this list of stuff that's easy to miss:

Reviewer Notes

If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.

Seems like bumping the golangci version
(tektoncd/plumbing#430) revealed some new
linting issues.

Pointers to items being ranged over are reused, so if this pointer is
stored anywhere and used later, it can lead to bugs.

I didn't see any reason why this needed to be a pointer so passing
around the value instead.
@tekton-robot tekton-robot requested review from dlorenc and a user June 18, 2020 17:02
@tekton-robot tekton-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 18, 2020
@tekton-robot
Copy link
Collaborator

This PR cannot be merged: expecting exactly one kind/ label

Available kind/ labels are:

kind/bug: Categorizes issue or PR as related to a bug.
kind/flake: Categorizes issue or PR as related to a flakey test
kind/cleanup: Categorizes issue or PR as related to cleaning up code, process, or technical debt.
kind/design: Categorizes issue or PR as related to design.
kind/documentation: Categorizes issue or PR as related to documentation.
kind/feature: Categorizes issue or PR as related to a new feature.
kind/misc: Categorizes issue or PR as a miscellaneuous one.

1 similar comment
@tekton-robot
Copy link
Collaborator

This PR cannot be merged: expecting exactly one kind/ label

Available kind/ labels are:

kind/bug: Categorizes issue or PR as related to a bug.
kind/flake: Categorizes issue or PR as related to a flakey test
kind/cleanup: Categorizes issue or PR as related to cleaning up code, process, or technical debt.
kind/design: Categorizes issue or PR as related to design.
kind/documentation: Categorizes issue or PR as related to documentation.
kind/feature: Categorizes issue or PR as related to a new feature.
kind/misc: Categorizes issue or PR as a miscellaneuous one.

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbwsg

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

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 18, 2020
@tekton-robot
Copy link
Collaborator

This PR cannot be merged: expecting exactly one kind/ label

Available kind/ labels are:

kind/bug: Categorizes issue or PR as related to a bug.
kind/flake: Categorizes issue or PR as related to a flakey test
kind/cleanup: Categorizes issue or PR as related to cleaning up code, process, or technical debt.
kind/design: Categorizes issue or PR as related to design.
kind/documentation: Categorizes issue or PR as related to documentation.
kind/feature: Categorizes issue or PR as related to a new feature.
kind/misc: Categorizes issue or PR as a miscellaneuous one.

@bobcatfish bobcatfish added the kind/bug Categorizes issue or PR as related to a bug. label Jun 18, 2020
@bobcatfish
Copy link
Collaborator Author

pull-tekton-pipeline-build-tests

ahhh i guess i have to fix these all in one PR or this will always fail - a great case for multiple commits in one PR @vdemeester XD

I found it a bit hard to understand how to configure this but looking at
the example config
(https:/golangci/golangci-lint/blob/master/.golangci.example.yml)
this seems right.

Since we don't control these files, it makes sense to skip linting them.

Recently we bumped the linter, which pulled in a new version of gosec,
which started flagging "Implicit memory aliasing in for loop" in the
generated files. This is a bit weird but at least we know that the
values are being used immediately and not stored, so it seems (famous
last words) unlikely to hit the bug these are trying to catch
(this issue has an example of the kind of bug this catches:
https:/trailofbits/gosec/issues/1)

e.g. the code getting flagged:
```
		for key, val := range *in {
			var outVal *PipelineRunTaskRunStatus
			if val == nil {
				(*out)[key] = nil
			} else {
				in, out := &val, &outVal
				*out = new(PipelineRunTaskRunStatus)
				(*in).DeepCopyInto(*out)
			}
			(*out)[key] = outVal
		}
```
Using a pointer here caused us to get the warning "Implicit memory
aliasing in for loop" from gosec. Not to mention that functions with
side effects are hard to maintain and reason about over time, so
instead, we'll now have one function that gets the values to use and
we'll actually do the mutation outside the function, so no reason to
pass in a pointer.
@tekton-robot tekton-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 18, 2020
@bobcatfish
Copy link
Collaborator Author

Okay hopefully that was the last of the 3 issues that the linter caught!

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/pod/status.go 88.4% 86.7% -1.7

@dlorenc
Copy link
Contributor

dlorenc commented Jun 18, 2020

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 18, 2020
@bobcatfish
Copy link
Collaborator Author

sidecar tests failed 😩

/test pull-tekton-pipeline-integration-tests

@bobcatfish
Copy link
Collaborator Author

/test pull-tekton-pipeline-integration-tests

this time it's a different test failing, TestPipelineTaskTimeout

So far these are tests that have flaked before (not that im not sad about that!) so im assuming this doesnt have to do with my changes

/test pull-tekton-pipeline-integration-tests

@tekton-robot tekton-robot merged commit 2d9b67d into tektoncd:master Jun 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants