Skip to content

Commit

Permalink
fix: Rename 'gomnd' to 'mnd' ⚓ (#175)
Browse files Browse the repository at this point in the history
* fix: Rename 'gomnd' to 'mnd' ⚓
* fix: Update 'golangci-lint' tool ⚓
  • Loading branch information
gabyx authored Jun 14, 2024
1 parent ed90c2c commit a89d530
Show file tree
Hide file tree
Showing 44 changed files with 78 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .githooks/pre-commit/golint
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if
CGO_ENABLED=0 golangci-lint run \
--exclude-dirs /usr/local/go \
-E godot \
-E gomnd \
-E mnd \
-E goconst \
-E gochecknoinits \
-E nlreturn \
Expand Down
2 changes: 1 addition & 1 deletion githooks/apps/dialog/cmd/common/flags-file.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (f *fileFilterArgs) Type() string {
func (f *fileFilterArgs) Set(s string) error {
var filter settings.FileFilter

if split := strings.SplitN(s, "|", 2); len(split) > 1 { // nolint: gomnd
if split := strings.SplitN(s, "|", 2); len(split) > 1 { // nolint: mnd
filter.Name = split[0]
s = split[1]
}
Expand Down
2 changes: 1 addition & 1 deletion githooks/apps/dialog/cmd/common/flags-opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (i *indexArgs) Type() string {

func (i *indexArgs) Set(s string) error {

value, err := strconv.ParseInt(s, 10, 32) // nolint: gomnd
value, err := strconv.ParseInt(s, 10, 32) // nolint: mnd
if err != nil {
return cm.ErrorF("Could not parse index '%s'.", s)
}
Expand Down
2 changes: 1 addition & 1 deletion githooks/apps/dialog/gui/darwin/osascript.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
var osascripts embed.FS

const (
ExitCodeCancel = 5 // nolint: gomnd
ExitCodeCancel = 5 // nolint: mnd
)

// RunOSAScript runs Apple's `osascripts` to execute JavaScript or AppleScript.
Expand Down
2 changes: 1 addition & 1 deletion githooks/apps/dialog/gui/extra-buttons.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func addInvisiblePrefix(extraButtons []string) (res []string, err error) {

// getResultButtons gets the pressed button,
// First button is the Ok button (if not excluded), 2,3,... are extra buttons.
// nolint: gomnd
// nolint: mnd
func getResultButtons(out string, maxButtons int) res.General {
s := strings.TrimSpace(out)
cm.DebugAssert(strs.IsNotEmpty(s))
Expand Down
2 changes: 1 addition & 1 deletion githooks/apps/dialog/gui/options-zenity.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func getChoicesZenity(output string) (indices []uint) {
indices = make([]uint, 0, len(out))

for i := range out {
idx, err := strconv.ParseUint(out[i], 10, 32) // nolint: gomnd
idx, err := strconv.ParseUint(out[i], 10, 32) // nolint: mnd
if err == nil {
indices = append(indices, uint(idx))
}
Expand Down
2 changes: 1 addition & 1 deletion githooks/apps/dialog/gui/windows/com.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type comObject struct{}
func (o *comObject) Call(trap uintptr, a ...uintptr) (r1, r2 uintptr, lastErr error) {
self := uintptr(unsafe.Pointer(o))
nargs := uintptr(len(a))
// nolint: gomnd
// nolint: mnd
switch nargs {
case 0:
return syscall.Syscall(trap, nargs+1, self, 0, 0)
Expand Down
4 changes: 2 additions & 2 deletions githooks/apps/dialog/gui/windows/dialog.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ func centerOnScreen(app *walk.Dialog) {
hScreen := int(win.GetSystemMetrics(win.SM_CYSCREEN))

rect := app.Bounds()
rect.X = wScreen/2 - rect.Width/2 // nolint: gomnd
rect.Y = hScreen/2 - rect.Height/2 // nolint: gomnd
rect.X = wScreen/2 - rect.Width/2 // nolint: mnd
rect.Y = hScreen/2 - rect.Height/2 // nolint: mnd
_ = app.SetBounds(rect)
}

Expand Down
6 changes: 3 additions & 3 deletions githooks/apps/dialog/gui/windows/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func defineEntryButtons(app *EntryApp, entry *sets.Entry, r *res.Entry) []Widget
okCallback, cancelCallback, extraButtonCallback)
}

// nolint: gomnd
// nolint: mnd
func defineDefaultEntry(app *EntryApp, opts *sets.Entry, addTextIcon bool) (w []Widget) {

app.icon = getIcon(opts.WindowIcon)
Expand Down Expand Up @@ -96,7 +96,7 @@ func defineEntryEdit(app *EntryApp, opts *sets.Entry) Widget {
}

// Shows an entry dialog.
// nolint: gomnd
// nolint: mnd
func ShowEntry(ctx context.Context, entry *sets.Entry) (r res.Entry, err error) {

app := &EntryApp{}
Expand All @@ -118,7 +118,7 @@ func ShowEntry(ctx context.Context, entry *sets.Entry) (r res.Entry, err error)
defaultButton, cancelButton = cancelButton, defaultButton
}

// nolint: gomnd
// nolint: mnd
m := Dialog{
AssignTo: &app.Dialog,
Title: entry.Title,
Expand Down
6 changes: 3 additions & 3 deletions githooks/apps/dialog/gui/windows/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func defineMessageButtons(app *MessageApp, msg *sets.Message, r *res.Message) []
okCallback, cancelCallback, extraButtonCallback)
}

// nolint: gomnd
// nolint: mnd
func defineMessageText(app *MessageApp, msg *sets.Message, addTextIcon bool) (w []Widget) {

app.icon = getIcon(msg.WindowIcon)
Expand Down Expand Up @@ -100,7 +100,7 @@ func defineMessageText(app *MessageApp, msg *sets.Message, addTextIcon bool) (w
}

// Shows an Message dialog.
// nolint: gomnd
// nolint: mnd
func ShowMessage(ctx context.Context, msg *sets.Message) (r res.Message, err error) {

app := &MessageApp{}
Expand All @@ -124,7 +124,7 @@ func ShowMessage(ctx context.Context, msg *sets.Message) (r res.Message, err err
defaultButton, cancelButton = cancelButton, defaultButton
}

// nolint: gomnd
// nolint: mnd
m := Dialog{
AssignTo: &app.Dialog,
Title: msg.Title,
Expand Down
2 changes: 1 addition & 1 deletion githooks/apps/dialog/gui/windows/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func wtsMessage(s *sets.Notification) error {
cm.AssertNoErrorPanic(err, "Conversion string to UTF16 failed")

var res uint32
// nolint: gomnd
// nolint: mnd
success, _, err := wtsSendMessage.Call(
0, // WTS_CURRENT_SERVER_HANDLE
0xffffffff, // WTS_CURRENT_SESSION
Expand Down
14 changes: 7 additions & 7 deletions githooks/apps/dialog/gui/windows/open-file-ole.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ func pickFolders(ctx context.Context, s *sets.FileSelection) (r res.File, err er
runtime.LockOSThread()
defer runtime.UnlockOSThread()

hr, _, _ := coInitializeEx.Call(0, 0x6) //nolint: gomnd // COINIT_APARTMENTTHREADED|COINIT_DISABLE_OLE1DDE
hr, _, _ := coInitializeEx.Call(0, 0x6) //nolint: mnd // COINIT_APARTMENTTHREADED|COINIT_DISABLE_OLE1DDE

if hr != 0x80010106 { // nolint: gomnd // RPC_E_CHANGED_MODE
if hr != 0x80010106 { // nolint: mnd // RPC_E_CHANGED_MODE
if int32(hr) < 0 {
err = cm.ErrorF("Failed call 'coInitializeEx': error '%v'", syscall.Errno(hr))

Expand All @@ -55,7 +55,7 @@ func pickFolders(ctx context.Context, s *sets.FileSelection) (r res.File, err er

var dialog *iFileOpenDialog
hr, _, _ = coCreateInstance.Call(
_CLSID_FileOpenDialog, 0, 0x17, // nolint: gomnd // CLSCTX_ALL
_CLSID_FileOpenDialog, 0, 0x17, // nolint: mnd // CLSCTX_ALL
iIDiFileOpenDialog, uintptr(unsafe.Pointer(&dialog)))

if int32(hr) < 0 {
Expand All @@ -79,7 +79,7 @@ func pickFolders(ctx context.Context, s *sets.FileSelection) (r res.File, err er
flags |= 0x10000000 // FOS_FORCESHOWHIDDEN
}

hr, _, _ = dialog.Call(dialog.vtbl.SetOptions, uintptr(flags|0x68)) // nolint: gomnd
hr, _, _ = dialog.Call(dialog.vtbl.SetOptions, uintptr(flags|0x68)) // nolint: mnd
// FOS_NOCHANGEDIR|FOS_PICKFOLDERS|FOS_FORCEFILESYSTEM
if int32(hr) < 0 {
err = cm.ErrorF("Failed call 'dialog.SetOptions': error '%v'", syscall.Errno(hr))
Expand Down Expand Up @@ -143,7 +143,7 @@ func pickFolders(ctx context.Context, s *sets.FileSelection) (r res.File, err er
return
}

if hr == 0x800704c7 { //nolint: gomnd // ERROR_CANCELLED
if hr == 0x800704c7 { //nolint: mnd // ERROR_CANCELLED
return res.File{General: res.CancelResult()}, nil
}

Expand All @@ -169,7 +169,7 @@ func pickFolders(ctx context.Context, s *sets.FileSelection) (r res.File, err er
var ptr uintptr
hr, _, _ = item.Call(
item.vtbl.GetDisplayName,
0x80058000, // nolint: gomnd // SIGDN_FILESYSPATH
0x80058000, // nolint: mnd // SIGDN_FILESYSPATH
uintptr(unsafe.Pointer(&ptr)))
if int32(hr) < 0 {
err = cm.ErrorF("Failed call 'dialog.GetDisplayName': error '%v'", syscall.Errno(hr))
Expand Down Expand Up @@ -238,7 +238,7 @@ func browseForFolder(ctx context.Context, s *sets.FileSelection) (r res.File, er
func(wnd uintptr, msg uint32, lparam, data uintptr) uintptr {
if msg == 1 { // BFFMiNITIALIZED
sendMessage.Call( //nolint: errcheck
wnd, 1024+103, //nolint: gomnd
wnd, 1024+103, //nolint: mnd
/* BFFM_SETSELECTIONW */
1, /* TRUE */
data)
Expand Down
2 changes: 1 addition & 1 deletion githooks/apps/dialog/gui/windows/open-file.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func translateFileSelection(s *sets.FileSelection) (ofn openFileNameW, buf []uin

addSelectedFilenamesChars := 0
if s.MultipleSelection {
addSelectedFilenamesChars = 1024 * 256 //nolint: gomnd
addSelectedFilenamesChars = 1024 * 256 //nolint: mnd
}

buf = make([]uint16, maxPath+addSelectedFilenamesChars)
Expand Down
8 changes: 4 additions & 4 deletions githooks/apps/dialog/gui/windows/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func defineListButtons(app *OptionsApp, opts *sets.Options, r *res.Options) []Wi
okCallback, cancelCallback, extraButtonCallback)
}

// nolint: gomnd
// nolint: mnd
func defineListText(app *OptionsApp, opts *sets.Options, addTextIcon bool) (w []Widget) {

switch opts.WindowIcon {
Expand Down Expand Up @@ -118,8 +118,8 @@ func ShowOptions(ctx context.Context, opts *sets.Options) (r res.Options, err er

app := &OptionsApp{list: &ListModel{options: opts.Options}}

minSize := Size{Width: 240, Height: 240} // nolint: gomnd
size := walk.Size{Width: minSize.Width, Height: minSize.Height} // nolint: gomnd
minSize := Size{Width: 240, Height: 240} // nolint: mnd
size := walk.Size{Width: minSize.Width, Height: minSize.Height} // nolint: mnd

if opts.Width != 0 {
size.Width = int(opts.Width)
Expand All @@ -135,7 +135,7 @@ func ShowOptions(ctx context.Context, opts *sets.Options) (r res.Options, err er
defaultButton, cancelButton = cancelButton, defaultButton
}

// nolint: gomnd
// nolint: mnd
m := Dialog{
AssignTo: &app.Dialog,
Title: opts.Title,
Expand Down
4 changes: 2 additions & 2 deletions githooks/apps/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ func shouldRunUpdateCheck(settings *HookSettings) bool {
lastUpdateCheck, _, err := updates.GetUpdateCheckTimestamp(settings.InstallDir)
log.AssertNoErrorF(err, "Could get last update check time.")

return time.Since(lastUpdateCheck).Hours() > 24.0 //nolint: gomnd
return time.Since(lastUpdateCheck).Hours() > 24.0 //nolint: mnd
}

func executeLFSHooks(settings *HookSettings) {
Expand Down Expand Up @@ -1035,7 +1035,7 @@ func executeHooks(settings *HookSettings, hs *hooks.Hooks) {
var pool *threadpool.ThreadPool
if hooks.UseThreadPool && hs.GetHooksCount() > 1 {
log.Debug("Launching with thread pool")
p := threadpool.New(nThreads, 15) // nolint: gomnd
p := threadpool.New(nThreads, 15) // nolint: mnd
pool = &p
}

Expand Down
2 changes: 1 addition & 1 deletion githooks/cmd/common/install/install-mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type installModeType struct {

// InstallModeTypeV enumerates all types of install modes.
// Manual is the default install mode.
var InstallModeTypeV = &installModeType{None: 0, Manual: 0, Centralized: 1} // nolint:gomnd
var InstallModeTypeV = &installModeType{None: 0, Manual: 0, Centralized: 1} // nolint: mnd

// GetInstallMode returns the current set install mode of Githooks.
// Return `none`-value if not installed.
Expand Down
2 changes: 1 addition & 1 deletion githooks/cmd/common/install/install-prompts.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func PromptExistingRepos(
"Searching ...", "Still searching ...")
taskIn := GitDirsSearchTask{Dir: searchDir}

resultTask, err := cm.RunTaskWithProgress(&taskIn, log, 300*time.Second, settings) //nolint: gomnd
resultTask, err := cm.RunTaskWithProgress(&taskIn, log, 300*time.Second, settings) //nolint: mnd
if err != nil {
log.AssertNoErrorF(err, "Could not find Git directories in '%s'.", searchDir)
return //nolint: nlreturn
Expand Down
4 changes: 2 additions & 2 deletions githooks/cmd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func runList(ctx *ccm.CmdContext, gitOpts *GitOptions) {

maxLength := 0
for i := range pairs {
maxLength = math.MaxInt(maxLength, len(pairs[i].Key)+2) // nolint: gomnd
maxLength = math.MaxInt(maxLength, len(pairs[i].Key)+2) // nolint: mnd
}
keyFmt := strs.Fmt("%%-%vs", maxLength)

Expand Down Expand Up @@ -774,7 +774,7 @@ If unset 'docker' is used.`,

optsPSR := createOptionMap(true, false, true)

configSetOptions(enableCmd, setOpts, &optsPSR, ctx.Log, 1, 2) // nolint: gomnd
configSetOptions(enableCmd, setOpts, &optsPSR, ctx.Log, 1, 2) // nolint: mnd
enableCmd.Flags().BoolVar(&gitOpts.Local, "local", false, "Use the local Git configuration (default).")
enableCmd.Flags().BoolVar(&gitOpts.Global, "global", false, "Use the global Git configuration.")
configCmd.AddCommand(ccm.SetCommandDefaults(ctx.Log, enableCmd))
Expand Down
4 changes: 2 additions & 2 deletions githooks/cmd/installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func setupSettings(
CloneDir: cloneDir,
TempDir: tempDir,
LFSHooksCache: lfsHooksCache,
InstalledGitDirs: make(InstallSet, 10)}, // nolint: gomnd
InstalledGitDirs: make(InstallSet, 10)}, // nolint: mnd
install.UISettings{PromptCtx: promptx}
}

Expand Down Expand Up @@ -1463,7 +1463,7 @@ func runInstall(cmd *cobra.Command, ctx *ccm.CmdContext, vi *viper.Viper) error

func transformLegacyGitConfigSettings(log cm.ILogContext, internalUpdateFromVersion string) {
if strs.IsNotEmpty(internalUpdateFromVersion) {
if v, _ := version.NewSemver(internalUpdateFromVersion); v.Segments()[0] < 3 { // nolint: gomnd
if v, _ := version.NewSemver(internalUpdateFromVersion); v.Segments()[0] < 3 { // nolint: mnd
log.PanicF("Cannot install new version '%s' over current version '%s' < 3.\n"+
"Too much changed. Please uninstall this version fully\n"+
"(also in registered repositories) and then install the new version.",
Expand Down
4 changes: 2 additions & 2 deletions githooks/cmd/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func PrepareListHookState(
ctx.Log.DebugF("Accumuldated repository ignore patterns: '%q'.", ignores.HooksDir)

// Load all shared hooks
shared = hooks.NewSharedRepos(8) //nolint: gomnd
shared = hooks.NewSharedRepos(8) //nolint: mnd

shared[hooks.SharedHookTypeV.Repo], err = hooks.LoadRepoSharedHooks(ctx.InstallDir, repoDir)
ctx.Log.AssertNoErrorF(err, "Could not load repository shared hooks.")
Expand All @@ -100,7 +100,7 @@ func PrepareListHookState(
Ignores: &ignores,
isRepoTrusted: isTrusted,
isGithooksDisabled: isDisabled,
sharedIgnores: make(ignoresPerHooksDir, 10)} // nolint: gomnd
sharedIgnores: make(ignoresPerHooksDir, 10)} // nolint: mnd

return
}
Expand Down
2 changes: 1 addition & 1 deletion githooks/cmd/trust/trustHooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func getAllHooks(
shared hooks.SharedRepos,
state *list.ListingState) (allHooks []hooks.Hook) {

allHooks = make([]hooks.Hook, 0, 10+2*shared.GetCount()) // nolint: gomnd
allHooks = make([]hooks.Hook, 0, 10+2*shared.GetCount()) // nolint: mnd

gitx := git.NewCtxAt(repoDir)

Expand Down
2 changes: 1 addition & 1 deletion githooks/cmd/uninstaller/uninstaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func setupSettings(
InstallDir: installDir,
CloneDir: hooks.GetReleaseCloneDir(installDir),
TempDir: tempDir,
UninstalledGitDirs: make(UninstallSet, 10), // nolint: gomnd
UninstalledGitDirs: make(UninstallSet, 10), // nolint: mnd
LFSHooksCache: lfsHooksCache},
UISettings{PromptCtx: promptx}
}
Expand Down
4 changes: 2 additions & 2 deletions githooks/common/background.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func CreateDefaultProgressSettings(title string, titleStillRunning string) Progr
return ProgressSettings{
Title: title,
TitleStillRunning: titleStillRunning,
ProgressUpdateInterval: 100 * time.Millisecond, //nolint: gomnd
ProgressStillRunningAfter: 5 * time.Second} //nolint: gomnd
ProgressUpdateInterval: 100 * time.Millisecond, //nolint: mnd
ProgressStillRunningAfter: 5 * time.Second} //nolint: mnd
}

// RunTaskWithProgress runs a task with a progress spinner
Expand Down
2 changes: 1 addition & 1 deletion githooks/common/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func VerifyFile(file io.Reader, signature io.Reader, publicKey string) error {
hash := sig.Hash.New()

// Hash the content of the file
buf := make([]byte, 1024) // nolint:gomnd
buf := make([]byte, 1024) // nolint: mnd
for {
n, err := file.Read(buf)
if err == io.EOF {
Expand Down
2 changes: 1 addition & 1 deletion githooks/common/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func LoadJSON(file string, repr interface{}) error {

// StoreJSON stores a representation in a JSON file.
func StoreJSON(file string, repr interface{}) error {
jsonFile, err := os.OpenFile(file, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0664) //nolint: gomnd
jsonFile, err := os.OpenFile(file, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0664) //nolint: mnd
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion githooks/common/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ func (c *LogContext) RemoveFileWriter() {
// Moves the the write pointer to the end of the file.
func (c *LogContext) MoveFileWriterToEnd() {
if c.file != nil {
_, _ = c.file.Seek(0, 2) // nolint: gomnd
_, _ = c.file.Seek(0, 2) // nolint: mnd
}
}

Expand Down
4 changes: 2 additions & 2 deletions githooks/common/path-windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func IsExecutable(path string) bool {

_, _, e := syscall.Syscall(
procGetBinaryTypeW.Addr(),
2, //nolint: gomnd
2, //nolint: mnd
uintptr(unsafe.Pointer(pPath)),
uintptr(unsafe.Pointer(&t)),
0)
Expand All @@ -67,7 +67,7 @@ func IsWritable(path string) bool {
}

// Check if the user bit is enabled in file permission
if info.Mode().Perm()&(1<<(uint(7))) == 0 { //nolint: gomnd
if info.Mode().Perm()&(1<<(uint(7))) == 0 { //nolint: mnd
return false
}

Expand Down
Loading

0 comments on commit a89d530

Please sign in to comment.