Skip to content

pin golangci-lint version, fix linter errors - #2392

Open
MichaelMraka wants to merge 3 commits into
RedHatInsights:masterfrom
MichaelMraka:pr2
Open

MichaelMraka wants to merge 3 commits into
RedHatInsights:masterfrom
MichaelMraka:pr2

Conversation

@MichaelMraka

@MichaelMraka MichaelMraka commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Secure Coding Practices Checklist GitHub Link

Secure Coding Checklist

  • Input Validation
  • Output Encoding
  • Authentication and Password Management
  • Session Management
  • Access Control
  • Cryptographic Practices
  • Error Handling and Logging
  • Data Protection
  • Communication Security
  • System Configuration
  • Database Security
  • File Management
  • Memory Management
  • General Coding Practices

Summary by Sourcery

Pin the linter version and resolve lint findings while improving shared metrics definitions, shutdown handling, query configuration, and internal error responses.

Bug Fixes:

  • Fix graceful HTTP server shutdown by preserving context values while providing a fresh timeout after cancellation.
  • Standardize internal server error responses across administrative, database, and profiling endpoints.
  • Use shared constants for controller query fields and stable sorting to improve consistency and avoid linter issues.

Enhancements:

  • Centralize Prometheus metric namespaces, subsystems, and common labels across services.
  • Align certificate expiry metrics with the shared metrics configuration.

Build:

  • Pin the Docker-installed golangci-lint version to v2.15.0.

Centralize repeated Prometheus/API string literals so golangci-lint goconst
passes after the Go 1.27 / linter bump.
Derive the shutdown timeout from the request context without inheriting
cancellation, and drop the now-unneeded G118 exclusion.
@MichaelMraka
MichaelMraka requested a review from a team as a code owner November 12, 2026 16:11
@sourcery-ai

sourcery-ai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

API

Centralize Prometheus metric namespaces, subsystems, and label names while preserving the existing exported metric names, and apply those constants across metric definitions and registration.

  • base/metrics/certificate_expiry.go L17-18
  • base/metrics/certificate_expiry_test.go L44-45, L60-61, L81-82
  • base/metrics/metrics.go L12-38
  • evaluator/metrics.go L17-39, L61-69 (+3 small edits)
  • listener/metrics.go L34-62 (+3 small edits)
  • manager/middlewares/prometheus.go L35-43, L49-59 (+5 small edits)
  • tasks/vmaas_sync/metrics.go L27-49, L55-63, L76-84 (+4 small edits)
  • tasks/vmaas_sync/metrics_db.go L4, L15-16, L22-23
  • tasks/vmaas_sync/metrics_systems.go L5, L21-31

Route internal errors in the affected admin, database, and pprof handlers through a shared response helper without changing the returned status or JSON shape.

  • turnpike/controllers/admin.go L36-196 (7 small edits)
  • turnpike/controllers/database.go L34, L62, L89
  • turnpike/controllers/pprof.go L77
  • turnpike/controllers/response.go L1-11

Implementation

Use shared constants for system inventory sort and search fields, including the stable export ordering.

  • manager/controllers/advisory_systems.go L69-70
  • manager/controllers/advisory_systems_export.go L24-25, L89
  • manager/controllers/package_systems.go L21-22
  • manager/controllers/systems.go L25-26
  • manager/controllers/systems_export.go L75
  • manager/controllers/template_systems.go L22-23
  • manager/controllers/utils.go L31-32

Derive the server shutdown timeout from the request context without inheriting its cancellation, and remove the obsolete G118 linter exclusion.

  • base/utils/gin.go L123-124
  • .golangci.yml L96 (removed lines)

Configuration

Pin the golangci-lint installation in the Docker build to v2.15.0.

  • Dockerfile L51

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 17.64706% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.82%. Comparing base (a5f2edb) to head (992c302).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
turnpike/controllers/admin.go 0.00% 7 Missing ⚠️
turnpike/controllers/database.go 0.00% 3 Missing ⚠️
manager/middlewares/prometheus.go 0.00% 1 Missing ⚠️
tasks/vmaas_sync/metrics.go 0.00% 1 Missing ⚠️
turnpike/controllers/pprof.go 0.00% 1 Missing ⚠️
turnpike/controllers/response.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2392      +/-   ##
==========================================
- Coverage   66.82%   66.82%   -0.01%     
==========================================
  Files         157      158       +1     
  Lines        9080     9081       +1     
==========================================
  Hits         6068     6068              
- Misses       3010     3011       +1     
  Partials        2        2              
Flag Coverage Δ
unittests 66.82% <17.64%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants