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

Fix gocritic findings #292

Merged
merged 4 commits into from
Jan 7, 2025
Merged

Fix gocritic findings #292

merged 4 commits into from
Jan 7, 2025

Conversation

HeavyWombat
Copy link
Contributor

@HeavyWombat HeavyWombat commented Dec 16, 2024

Changes

While working on #291, I realized that my linter returned some minor findings in this repository.

Fix minor TYPO in hack/verify-docs.sh.

Resolve gocritic findings.

Remove trailing whitespaces.

Submitter Checklist

  • Includes tests if functionality changed/was added
  • Includes docs if changes are user-facing
  • Set a kind label on this PR
  • Release notes block has been filled in, or marked NONE

See the contributor guide
for details on coding conventions, github and prow interactions, and the code review process.

Release Notes

NONE

@HeavyWombat HeavyWombat added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Dec 16, 2024
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Dec 16, 2024
@@ -110,8 +110,7 @@ func (c *LogsCommand) Run(params *params.Params, ioStreams *genericclioptions.IO
fmt.Fprintf(ioStreams.Out, "Obtaining logs for BuildRun %q\n\n", c.name)

var b strings.Builder
containers := append(pod.Spec.InitContainers, pod.Spec.Containers...)
for _, container := range containers {
for _, container := range append(pod.Spec.InitContainers, pod.Spec.Containers...) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

./pkg/shp/cmd/buildrun/logs.go:113:17: appendAssign: append result not assigned to the same slice

Copy link
Contributor

Choose a reason for hiding this comment

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

never saw such range with append on the same line, nice.

@@ -107,8 +107,7 @@ func (f *Follower) Log(msg string) {
// tailLogs start tailing logs for each container name in init-containers and containers, if not
// started already.
func (f *Follower) tailLogs(pod *corev1.Pod) {
containers := append(pod.Spec.InitContainers, pod.Spec.Containers...)
for _, container := range containers {
for _, container := range append(pod.Spec.InitContainers, pod.Spec.Containers...) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

./pkg/shp/cmd/follower/follow.go:110:16: appendAssign: append result not assigned to the same slice

@@ -94,8 +94,6 @@ func (p *PodWatcher) WithNoPodEventsYetFn(fn NoPodEventsYetFn) *PodWatcher {

// handleEvent applies user informed functions against informed pod and event.
func (p *PodWatcher) handleEvent(pod *corev1.Pod, event watch.Event) error {
//p.stopLock.Lock()
//defer p.stopLock.Unlock()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably unused by now.

@@ -18,7 +18,7 @@ func (wc *writeCounter) Write(p []byte) (int, error) {
}

func trimPrefix(prefix, fpath string) string {
return strings.TrimPrefix(strings.Replace(fpath, prefix, "", -1), string(filepath.Separator))
return strings.TrimPrefix(strings.ReplaceAll(fpath, prefix, ""), string(filepath.Separator))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

./pkg/shp/streamer/util.go:21:28: wrapperFunc: use strings.ReplaceAll method in `strings.Replace(fpath, prefix, "", -1)`

Copy link
Contributor

@qu1queee qu1queee left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Dec 17, 2024
@qu1queee qu1queee removed the request for review from adambkaplan December 17, 2024 07:48
Copy link
Member

@SaschaSchwarze0 SaschaSchwarze0 left a comment

Choose a reason for hiding this comment

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

Thanks, looks good. Do you mind enabling the linter in .golangci.yml. Otherwise it won't take too long for new findings.

@SaschaSchwarze0 SaschaSchwarze0 added this to the release-v0.15.0 milestone Dec 24, 2024
Fix minor TYPO in `hack/verify-docs.sh`.

Signed-off-by: Matthias Diester <matthias.diester@de.ibm.com>
Resolve `gocritic` findings.

Signed-off-by: Matthias Diester <matthias.diester@de.ibm.com>
Remove trailing whitespaces.

Signed-off-by: Matthias Diester <matthias.diester@de.ibm.com>
@HeavyWombat HeavyWombat force-pushed the fix/go-critic-findings branch from d942093 to 514deb4 Compare January 7, 2025 16:12
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Jan 7, 2025
Add `gocritic` to the list of default linters.

Signed-off-by: Matthias Diester <matthias.diester@de.ibm.com>
@HeavyWombat HeavyWombat force-pushed the fix/go-critic-findings branch from 514deb4 to 32b23a6 Compare January 7, 2025 16:13
Copy link
Member

@SaschaSchwarze0 SaschaSchwarze0 left a comment

Choose a reason for hiding this comment

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

/approve
/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 7, 2025
Copy link
Contributor

openshift-ci bot commented Jan 7, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: SaschaSchwarze0

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 openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 7, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit 6544572 into main Jan 7, 2025
12 checks passed
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/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. release-note-none size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants