Skip to content

Improve formatting, error handling. Fixed typos.#600

Merged
yorukot merged 9 commits into
mainfrom
fix_formatting
Feb 13, 2025
Merged

Improve formatting, error handling. Fixed typos.#600
yorukot merged 9 commits into
mainfrom
fix_formatting

Conversation

@lazysegtree

@lazysegtree lazysegtree commented Feb 8, 2025

Copy link
Copy Markdown
Collaborator
➜  ~/Workspace/kuknitin/superfile/src git:(fix_formatting) [2:06:14] golangci-lint run
internal/config_function.go:310:13: Error return value of `file.Write` is not checked (errcheck)
		file.Write(src)
		          ^
internal/config_function.go:314:14: Error return value of `os.WriteFile` is not checked (errcheck)
	os.WriteFile(variable.ThemeFileVersion, []byte(variable.CurrentVersion), 0644)
	            ^
internal/function.go:413:18: Error return value of `filepath.WalkDir` is not checked (errcheck)
	filepath.WalkDir(path, func(_ string, entry os.DirEntry, err error) error {
	                ^
internal/handle_file_operations.go:530:14: Error return value of `os.MkdirAll` is not checked (errcheck)
		os.MkdirAll(outputDir, 0755)
		           ^
internal/handle_file_operations.go:536:14: Error return value of `os.MkdirAll` is not checked (errcheck)
		os.MkdirAll(outputDir, 0755)
		           ^
internal/handle_file_operations.go:556:11: Error return value is not checked (errcheck)
	zipSource(panel.element[panel.cursor].location, filepath.Join(filepath.Dir(panel.element[panel.cursor].location), zipName))
	         ^
➜  ~/Workspace/kuknitin/superfile/src git:(fix_formatting) [2:06:43]

Its A+ now in this branch. (main branch is B - https://goreportcard.com/report/github.com/yorukot/superfile )

➜  ~/Workspace/kuknitin/superfile git:(fix_formatting) ✗ [3:02:23] goreportcard-cli -v
Grade ........... A+ 97.1%
Files ................. 33
Issues ................. 8
gofmt ............... 100%
go_vet .............. 100%
gocyclo .............. 75%
	src/internal/model_render.go
		Line 79: warning: cyclomatic complexity 29 of function (*model).filePanelRender() is high (> 15) (gocyclo)
		Line 587: warning: cyclomatic complexity 28 of function (*model).filePreviewPanelRender() is high (> 15) (gocyclo)
		Line 458: warning: cyclomatic complexity 22 of function (*model).helpMenuRender() is high (> 15) (gocyclo)
		Line 195: warning: cyclomatic complexity 18 of function (*model).processBarRender() is high (> 15) (gocyclo)
	src/internal/file_operations.go
		Line 163: warning: cyclomatic complexity 21 of function pasteDir() is high (> 15) (gocyclo)
	src/internal/file_operations_extract.go
		Line 87: warning: cyclomatic complexity 20 of function unzip() is high (> 15) (gocyclo)
	src/internal/function.go
		Line 282: warning: cyclomatic complexity 20 of function (*model).returnMetaData() is high (> 15) (gocyclo)
		Line 45: warning: cyclomatic complexity 16 of function returnDirElement() is high (> 15) (gocyclo)
	src/internal/handle_panel_movement.go
		Line 410: warning: cyclomatic complexity 18 of function (*model).controlSideBarListUp() is high (> 15) (gocyclo)
		Line 478: warning: cyclomatic complexity 17 of function (*model).controlSideBarListDown() is high (> 15) (gocyclo)
	src/internal/handle_file_operations.go
		Line 401: warning: cyclomatic complexity 16 of function (*model).pasteItem() is high (> 15) (gocyclo)
	src/internal/config_function.go
		Line 246: warning: cyclomatic complexity 16 of function LoadAllDefaultConfig() is high (> 15) (gocyclo)
	src/internal/key_function.go
		Line 17: warning: cyclomatic complexity 35 of function (*model).mainKey() is high (> 15) (gocyclo)
		Line 139: warning: cyclomatic complexity 23 of function (*model).normalAndBrowserModeKey() is high (> 15) (gocyclo)
ineffassign ......... 100%
license ............. 100%
misspell ............ 100%
➜  ~/Workspace/kuknitin/superfile git:(fix_formatting) ✗ [3:02:30]

@netlify

netlify Bot commented Feb 8, 2025

Copy link
Copy Markdown

Deploy Preview for superfile canceled.

Name Link
🔨 Latest commit d04e584
🔍 Latest deploy log https://app.netlify.com/sites/superfile/deploys/67aa2c8040d2740007e86f14

@lazysegtree lazysegtree changed the title Fix formatting Improve go reportcard Feb 8, 2025
@lazysegtree lazysegtree force-pushed the fix_formatting branch 3 times, most recently from 5c711a8 to 03f5173 Compare February 8, 2025 09:38
@lazysegtree lazysegtree changed the title Improve go reportcard Improve formatting, error handling. Fixed typos. Feb 8, 2025
- name: Test
run: go test ./...

- name: Test `go fmt` creates no diffs

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.58

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ref : https://cicube.io/workflow-hub/golangci-golangci-lint-action/

Pinning a specific version is recommended to prevent unpredictable builds if a new version of golangci-lint introduces breaking changes.
Without with, latest version will be used

@lazysegtree

Copy link
Copy Markdown
Collaborator Author
image

Thats how the badges look right now. Go report will be A+ after this merge.

uses: actions/setup-go@v5
with:
go-version: 1.21
go-version: 1.22.2

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Updated it to match our version in go.mod

}
}

package internal

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I dont know why this file is just recreated, But that what go fmt did.

@lazysegtree lazysegtree marked this pull request as ready for review February 10, 2025 16:29
@lazysegtree lazysegtree requested a review from yorukot February 10, 2025 16:30

// Move file to trash can and can auto switch macos trash can or linux trash can
func trashMacOrLinux(src string) error {
var err error

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Removed code duplication here.

@lazysegtree

Copy link
Copy Markdown
Collaborator Author

@yorukot @BhagatHarsh I have finished the changes. Please review.

@BhagatHarsh

Copy link
Copy Markdown
Contributor

I don't know about the version updates.

The formatting looks good, very thorough spellcheck 🚀 .

@yorukot yorukot merged commit 25a5ad9 into main Feb 13, 2025
@lazysegtree lazysegtree deleted the fix_formatting branch February 14, 2025 03:27
@jachewz jachewz mentioned this pull request Feb 20, 2025
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.

3 participants