Skip to content

Prefer %v over %d,%s and add fmtpercentv custom linter - #3756

Merged
gmlewis merged 4 commits into
google:masterfrom
gmlewis:add-url-percent-v-linter
Oct 6, 2025
Merged

Prefer %v over %d,%s and add fmtpercentv custom linter#3756
gmlewis merged 4 commits into
google:masterfrom
gmlewis:add-url-percent-v-linter

Conversation

@gmlewis

@gmlewisgmlewis commented Oct 4, 2025

Copy link
Copy Markdown
Collaborator

This PR formalizes the preference of %v over the use of %s or %d in this repo by adding a custom linter that enforces this preference.

Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
@codecov

codecovBot commented Oct 4, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.43537% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.11%. Comparing base (6195c56) to head (69c428e).
⚠️ Report is 1 commits behind head on master.

Files with missing linesPatch %Lines
example/commitpr/main.go0.00%6 Missing ⚠️
example/actionpermissions/main.go0.00%5 Missing ⚠️
example/verifyartifact/main.go0.00%3 Missing ⚠️
example/listenvironments/main.go0.00%1 Missing ⚠️
example/ratelimit/main.go0.00%1 Missing ⚠️
github/repos_contents.go90.90%1 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@## master #3756 +/- ##
=======================================
Coverage 91.11% 91.11% =======================================
Files 187 187 Lines 16702 16702 =======================================
Hits 15218 15218 Misses 1296 1296 Partials 188 188 

☔ View full report in Codecov by Sentry.
📢 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.

@gmlewisgmlewis added the NeedsReview PR is awaiting a review before merging. label Oct 4, 2025
@gmlewis

Copy link
Copy Markdown
CollaboratorAuthor

@stevehipwell - @alexandear - @zyfy29 - might you have time for a code review? Thank you!

Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
@gmlewisgmlewis changed the title Prefer %v over %d,%s and add urlpercentv custom linterPrefer %v over %d,%s and add fmtpercentv custom linterOct 5, 2025
Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
@gmlewis

Copy link
Copy Markdown
CollaboratorAuthor

OK, great idea, @zyfy29! I've renamed urlpercentv to fmtpercentv and generalized it to lint all call expression format strings, not just ones involving assignments. This only flagged 3 perfectly valid lines in the entire repo, so I've gone ahead and added the //nolint comments to those.

PTAL.

@gmlewis

Copy link
Copy Markdown
CollaboratorAuthor

Thank you, @zyfy29!
Merging.

@gmlewisgmlewis removed the NeedsReview PR is awaiting a review before merging. label Oct 6, 2025
@gmlewis
gmlewis merged commit 4505771 into google:masterOct 6, 2025
6 of 7 checks passed
@gmlewis
gmlewis deleted the add-url-percent-v-linter branch October 6, 2025 01:40
jlaportebot added a commit to jlaportebot/go-github that referenced this pull request Jun 28, 2026
Sign up for freeto 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.

1 participant

@gmlewis