Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused internal or unexported functions #3481

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

alexandear
Copy link
Contributor

This PR removes unused internal or unexported functions reported by the deadcode analyzer.

Details
❯ deadcode ./...
internal/action/infocomplete.go:138:6: unreachable func: contains
internal/buffer/line_array.go:289:22: unreachable func: LineArray.deleteByte
internal/config/plugin.go:148:6: unreachable func: FindAnyPlugin
internal/config/rtfiles.go:102:21: unreachable func: namedFile.Name
internal/screen/screen.go:240:6: unreachable func: InitSimScreen
internal/util/profile.go:19:6: unreachable func: Tic
internal/util/profile.go:24:6: unreachable func: Toc
internal/util/util.go:238:6: unreachable func: IsUpperWordChar
internal/util/util.go:244:6: unreachable func: IsLowerWordChar
internal/util/util.go:514:6: unreachable func: ParseSpecial
pkg/highlight/highlighter.go:54:6: unreachable func: combineLineMatch
pkg/highlight/parser.go:268:6: unreachable func: HasIncludes
pkg/highlight/parser.go:276:6: unreachable func: hasIncludesInRegion
pkg/highlight/unicode.go:39:6: unreachable func: DecodeCharacterInString
pkg/highlight/unicode.go:75:6: unreachable func: CharacterCountInString

@alexandear alexandear changed the title Remove unused internal functions Remove unused internal or unexported functions Sep 23, 2024
func Toc(start time.Time) {
end := time.Now()
log.Println("END: ElapsedTime in seconds:", end.Sub(start))
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

These may be actually occasionally useful for profiling?

BTW I didn't even know about the existence of this internal/util/profile.go until now (and I find it rather nice). (And BTW also I didn't know about the existence of the memusage command.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not a big deal to write two lines when we need to profile something. For now, I propose removing redundant code that is not used.

Copy link
Collaborator

Choose a reason for hiding this comment

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

What exactly would we achieve by removing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing unnecessary functions will allow refactoring the util package into something more meaningful with a better name.

The package name util is considered a bad package name according to https://go.dev/blog/package-names#bad-package-names.

Copy link
Collaborator

Choose a reason for hiding this comment

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

refactoring the util package into something more meaningful with a better name.

Like what?

Copy link
Collaborator

@JoeKar JoeKar Sep 30, 2024

Choose a reason for hiding this comment

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

The package name util is considered a bad package name according to https://go.dev/blog/package-names#bad-package-names.

So it's the usual ideal world example which would have been nice in the moment it has been respected from the beginning. But unfortunately the world isn't ideal, it hasn't been considered from the beginning and thus util is grown historically by throwing everything into it which doesn't fit into the other base packages.
I wouldn't say that we're against such a cleanup process, but currently we've bigger construction sites at other places.

Like what?

As said by @dmaluka or at least how I interpret it:
If you have a much better suggestion, please go ahead.
But remember, especially with the lua.go in util we most probably face problems with plugin interfaces.

internal/config/rtfiles.go Show resolved Hide resolved
internal/util/util.go Show resolved Hide resolved
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.

4 participants