Skip to content

Enable Go nil pointer linting, and consider other opportunities to improve linting. #32999

@lukeheath

Description

@lukeheath

Goal

User story
As a Fleet contributor,
I want to eliminate nil pointer dereference issues at runtime and add additional linting checks
to improve Fleet quality.

Proposal: Use NilAway with golangci-lint v2 incremental run --new-from-rev=origin/${{ github.base_ref }}, which would be an additional golangci-lint run.

  • switches -include-pkgs="github.com/fleetdm/fleet/v4" -test=false

We would have 2 golangci-lint runs. One catches all issues globally, and one (with a different set of linters) only catching issues on incremental changes. The goal would be to eventually move all linters from the incremental check to the global check.

Evaluate other linters:

  • modernize!!!
  • bodyclose: Checks whether HTTP response body is closed successfully.
  • noctx: Detects function and method with missing usage of context.Context.
  • forbidigo fmt\.Print.*(# Do not commit print statements\.)?
  • errorlint: Find code that can cause problems with the error wrapping scheme introduced in Go 1.13.
  • testifylint: Checks usage of github.com/stretchr/testify.
  • exhaustive: Check exhaustiveness of enum switch statements.
  • errchkjson: Checks types passed to the json encoding functions. Reports unsupported types and reports occurrences where the check for the returned error can be omitted.
  • bidichk: Checks for dangerous unicode character sequences.

Roadmap item

Original requests

Context

  • Product Designer: @getvictor
  • Engineer: _________________________

Changes

Product

  • NA

Engineering

  • Update CI pipeline

ℹ️  Please read this issue carefully and understand it. Pay special attention to UI wireframes, especially "dev notes".

QA

NA

Test plan

NA

Metadata

Metadata

Labels

#g-security-complianceSecurity & Compliance product group:releaseReady to write code. Scheduled in a release. See "Making changes" in handbook.storyA user story defining an entire feature~engineering-initiatedEngineering-initiated story, such as a bug, refactor, or contributor experience improvement.~postmortem-action-itemIssue is an action item resulting from an incident postmortem.

Type

No type

Projects

Status

Done

Status

Done

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions