Skip to content

add lint and fix some issue - #11

Merged
kazeburo merged 1 commit into
mainfrom
feat/lint-and-fix
Jul 30, 2026
Merged

add lint and fix some issue#11
kazeburo merged 1 commit into
mainfrom
feat/lint-and-fix

Conversation

@kazeburo

@kazeburo kazeburo commented Jul 30, 2026

Copy link
Copy Markdown
Member

User description

  • add golangci.yml and make lint
  • fix for some lint errors

PR Type

Enhancement, Bug fix


Description

  • Add .golangci.yml configuration for static analysis

  • Introduce lint target to the Makefile

  • Suppress unused error returns in statsfile.go

  • Refactor TCP metric extraction in usageplugin.go


Diagram Walkthrough

flowchart LR
  Makefile["Makefile"] -- "adds target" --> golangci["golangci-lint"]
  golangci -- "loads config" --> golangci_yml[".golangci.yml"]
  statsfile["statsfile.go"] -- "suppresses errors" --> errcheck["errcheck"]
  usageplugin["usageplugin.go"] -- "refactors code" --> ineffassign["ineffassign"]
Loading

File Walkthrough

Relevant files
Bug fix
statsfile.go
Suppress unused error returns in temporary file handling 

statsfile.go

  • Replaces direct error returns with blank identifier assignment
+2/-2     
Enhancement
usageplugin.go
Refactor TCP metric extraction to use local variable         

usageplugin.go

  • Introduces local variable for TCP struct to reduce field access
+5/-4     
Configuration changes
.golangci.yml
Add comprehensive golangci-lint configuration for static analysis

.golangci.yml

  • Adds static analysis configuration with multiple enabled linters
+35/-0   
Makefile
Add lint makefile target for running static analysis         

Makefile

  • Adds lint target to run golangci-lint with timeout
+2/-0     

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ No major issues detected

@github-actions

Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Centralize errcheck exclusions in config

Instead of using _ = os.Remove(...) to silence the errcheck linter, add os.Remove to
the exclude-functions list in .golangci.yml. This keeps the code cleaner and
centralizes lint exceptions.

statsfile.go [30-40]

 if err != nil {
 	newFile.Close()
-	_ = os.Remove(newFile.Name())
+	os.Remove(newFile.Name())
 	return err
 }
 
 err = newFile.Close()
 if err != nil {
-	_ = os.Remove(newFile.Name())
+	os.Remove(newFile.Name())
 	return err
 }
Suggestion importance[1-10]: 5

__

Why: Centralizing linter exclusions in the config file improves code cleanliness and maintainability, though it is a minor stylistic improvement rather than a critical fix.

Low
Add trailing newline to Makefile

Add a trailing newline to the end of the Makefile. Missing newlines can cause issues
with some POSIX-compliant tools and linters, and is a standard requirement for text
files.

Makefile [18-19]

+lint:
+	golangci-lint run --timeout 5m ./...
 
-
Suggestion importance[1-10]: 3

__

Why: Adding a trailing newline is a minor formatting fix that improves POSIX compliance but has negligible impact on functionality or correctness.

Low

@kazeburo
kazeburo merged commit 2e945d5 into main Jul 30, 2026
3 checks passed
@kazeburo
kazeburo deleted the feat/lint-and-fix branch July 30, 2026 13:21
@github-actions github-actions Bot mentioned this pull request Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant