Skip to content

Commit 4b60153

Browse files
committed
refactor: standardize TODO comments across the codebase
1 parent 98ba124 commit 4b60153

26 files changed

+101
-101
lines changed

.golangci.yaml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ linters:
269269
- bodyclose # checks whether HTTP response body is closed successfully
270270
- canonicalheader # checks whether net/http.Header uses canonical header
271271
- copyloopvar # detects places where loop variables are copied (Go 1.22+)
272-
# Todo enable this - This needs a fix in few of our functions
272+
# TODO enable this - This needs a fix in few of our functions
273273
#- cyclop # checks function and package cyclomatic complexity
274274
- depguard # checks if package imports are in a list of acceptable packages
275275
- dupl # tool for code clone detection
@@ -280,38 +280,38 @@ linters:
280280
- exptostd # detects functions from golang.org/x/exp/ that can be replaced by std functions
281281
- fatcontext # detects nested contexts in loops
282282
# - forbidigo # forbids identifiers # Not needed. this blocks only fmt.Print family and is not useful right now
283-
# Todo enable - need to make functions shorter
283+
# TODO enable - need to make functions shorter
284284
#- funlen # tool for detection of long functions
285285
- gocheckcompilerdirectives # validates go compiler directive comments (//go:)
286-
# Todo enable - This is too much for us right now
286+
# TODO enable - This is too much for us right now
287287
- gochecknoglobals # checks that no global variables exist
288288
- gochecknoinits # checks that no init functions are present in Go code
289289
- gochecksumtype # checks exhaustiveness on Go "sum types"
290-
# Todo enable - Need to refactor many functions
290+
# TODO enable - Need to refactor many functions
291291
# - gocognit # computes and checks the cognitive complexity of functions
292292
- goconst # finds repeated strings that could be replaced by a constant
293293
- gocritic # provides diagnostics that check for bugs, performance and style issues
294-
# Todo enable
294+
# TODO enable
295295
#- gocyclo # computes and checks the cyclomatic complexity of functions
296296
#- godot # checks if comments end in a period # Too much for us right now
297297
- goimports # in addition to fixing imports, goimports also formats your code in the same style as gofmt
298298
- gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod
299299
- goprintffuncname # checks that printf-like functions are named with f at the end
300-
# Todo enable - ignore for a few int overflow, and fix file permissions
300+
# TODO enable - ignore for a few int overflow, and fix file permissions
301301
# weak md5 cryptography, Subprocess launched with a potential tainted input
302302
# - gosec # inspects source code for security problems
303303
- iface # checks the incorrect use of interfaces, helping developers avoid interface pollution
304304
- intrange # finds places where for loops could make use of an integer range
305-
# Todo enable : Need many fixes
305+
# TODO enable : Need many fixes
306306
# - lll # reports long lines
307307
- loggercheck # checks key value pairs for common logger libraries (kitlog,klog,logr,zap)
308308
- makezero # finds slice declarations with non-zero initial length
309309
- mirror # reports wrong mirror patterns of bytes/strings usage
310-
# Todo enable - Many many magic numbers, and this should be fixed.
310+
# TODO enable - Many many magic numbers, and this should be fixed.
311311
# - mnd # detects magic numbers
312312
- musttag # enforces field tags in (un)marshaled structs
313313
- nakedret # finds naked returns in functions greater than a specified function length
314-
# Todo enable : Many reports. A bit hard to understand the nesting value.
314+
# TODO enable : Many reports. A bit hard to understand the nesting value.
315315
# - nestif # reports deeply nested if statements
316316
- nilerr # finds the code that returns nil even if it checks that the error is not nil
317317
- nilnesserr # reports that it checks for err != nil, but it returns a different nil value error (powered by nilness and nilerr)
@@ -325,11 +325,11 @@ linters:
325325
- promlinter # checks Prometheus metrics naming via promlint
326326
- protogetter # reports direct reads from proto message fields when getters should be used
327327
- reassign # checks that package variables are not reassigned
328-
# Todo enable - Issue due to model struct
328+
# TODO enable - Issue due to model struct
329329
# - recvcheck # checks for receiver type consistency
330330
- revive # fast, configurable, extensible, flexible, and beautiful linter for Go, drop-in replacement of golint
331331
- rowserrcheck # checks whether Err of rows is checked successfully
332-
# Todo enable - Need to use non-root logger
332+
# TODO enable - Need to use non-root logger
333333
# - sloglint # ensure consistent code style when using log/slog
334334
- spancheck # checks for mistakes with OpenTelemetry/Census spans
335335
- sqlclosecheck # checks that sql.Rows and sql.Stmt are closed
@@ -345,7 +345,7 @@ linters:
345345
- wastedassign # finds wasted assignment statements
346346
- whitespace # detects leading and trailing whitespace
347347

348-
## Todo : Enable some of them
348+
## TODO : Enable some of them
349349
## you may want to enable
350350
- decorder # checks declaration order and count of types, constants, variables and functions
351351
# We have so many false positives

src/internal/common/predefined_variable.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var (
1515
MinimumHeight = 24
1616
MinimumWidth = 60
1717

18-
// Todo : These are model object properties, not global properties
18+
// TODO : These are model object properties, not global properties
1919
// We are modifying them in the code many time. They need to be part of model struct.
2020
MinFooterHeight = 6
2121
ModalWidth = 60
@@ -53,7 +53,7 @@ func LoadInitialPrerenderedVariables() {
5353
lipgloss.NewStyle().Foreground(lipgloss.Color("#00FFEE")).Render(" ┃ ")
5454
}
5555

56-
// Dependecies - Todo We should programmatically guarantee these dependencies. And log error
56+
// Dependecies - TODO We should programmatically guarantee these dependencies. And log error
5757
// if its not satisfied.
5858
// LoadThemeConfig() in style.go should be finished
5959
// loadConfigFile() in config_types.go should be finished

src/internal/common/string_function.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func TruncateMiddleText(text string, maxChars int, tails string) string {
5252
}
5353

5454
halfEllipsisLength := (maxChars - 3) / 2
55-
// Todo : Use ansi.Substring to correctly handle ANSI escape codes
55+
// TODO : Use ansi.Substring to correctly handle ANSI escape codes
5656
truncatedText := text[:halfEllipsisLength] + tails + text[utf8.RuneCountInString(text)-halfEllipsisLength:]
5757

5858
return truncatedText
@@ -114,7 +114,7 @@ func FormatFileSize(size int64) string {
114114
unitsDec := []string{"B", "kB", "MB", "GB", "TB", "PB", "EB"}
115115
unitsBin := []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"}
116116

117-
// Todo : Remove duplication here
117+
// TODO : Remove duplication here
118118
if Config.FileSizeUseSI {
119119
unitIndex := int(math.Floor(math.Log(float64(size)) / math.Log(1000)))
120120
adjustedSize := float64(size) / math.Pow(1000, float64(unitIndex))

src/internal/common/style_function.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ func LoadHotkeysError(value string) string {
237237
return lipgloss.NewStyle().Foreground(lipgloss.Color("#FF5555")).Render("■ ERROR: ") + "Hotkeys file \"" + lipgloss.NewStyle().Foreground(lipgloss.Color("#00D9FF")).Render(value) + "\" invalidation"
238238
}
239239

240-
// Todo : Fix Code duplication in textInput.Model creation
240+
// TODO : Fix Code duplication in textInput.Model creation
241241
// This eventually caused a bug, where we created new model for sidebar search, and
242242
// Didn't set `Width` in that. Take Width and other parameters as input in one function
243243
// Generate search bar for file panel

src/internal/config_function.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func initialConfig(firstFilePanelDirs []string) (toggleDotFile bool, toggleFoote
2424
// Open log stream
2525
file, err := os.OpenFile(variable.LogFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
2626

27-
// Todo : This could be improved if we want to make superfile more resilient to errors
27+
// TODO : This could be improved if we want to make superfile more resilient to errors
2828
// For example if the log file directories have access issues.
2929
// we could pass a dummy object to log.SetOutput() and the app would still function.
3030
if err != nil {

src/internal/function.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
)
2626

2727
// Check if the directory is external disk path
28-
// Todo : This function should be give two directories, and it should return
28+
// TODO : This function should be give two directories, and it should return
2929
// if the two share a different disk partition.
3030
// Ideally we shouldn't even try to figure that out in our file operations, and let OS handles it.
3131
// But at least right now its not okay. This returns if `path` is an External disk
@@ -58,7 +58,7 @@ func returnFocusType(focusPanel focusPanelType) filePanelFocusType {
5858
return secondFocus
5959
}
6060

61-
// Todo : Take common.Config.CaseSensitiveSort as a function parameter
61+
// TODO : Take common.Config.CaseSensitiveSort as a function parameter
6262
// and also consider testing this caseSensitive with both true and false in
6363
// our unit_test TestReturnDirElement
6464
func returnDirElement(location string, displayDotFile bool, sortOptions sortOptionsModelData) []element {
@@ -83,7 +83,7 @@ func returnDirElement(location string, displayDotFile bool, sortOptions sortOpti
8383
var order func(i, j int) bool
8484
reversed := sortOptions.reversed
8585

86-
// Todo : These strings should not be hardcoded here, but defined as constants
86+
// TODO : These strings should not be hardcoded here, but defined as constants
8787
switch sortOptions.options[sortOptions.selected] {
8888
case "Name":
8989
order = func(i, j int) bool {
@@ -223,7 +223,7 @@ func panelElementHeight(mainPanelHeight int) int {
223223
return mainPanelHeight - 3
224224
}
225225

226-
// Todo : replace usage of this with slices.contains
226+
// TODO : replace usage of this with slices.contains
227227
func arrayContains(s []string, str string) bool {
228228
for _, v := range s {
229229
if v == str {
@@ -310,7 +310,7 @@ func renameIfDuplicate(destination string) (string, error) {
310310
}
311311
}
312312

313-
// Todo : Move this model related function to the right file. Should not be in functions file.
313+
// TODO : Move this model related function to the right file. Should not be in functions file.
314314
func (m *model) returnMetaData() {
315315
panel := m.fileModel.filePanels[m.filePanelFocusIndex]
316316
cursor := panel.cursor
@@ -366,7 +366,7 @@ func (m *model) returnMetaData() {
366366
if fileInfo.IsDir() {
367367
m.fileMetaData.metaData = append(m.fileMetaData.metaData, [2]string{"Name", fileInfo.Name()})
368368
if m.focusPanel == metadataFocus {
369-
// Todo : Calling dirSize() could be expensive for large directories, as it recursively
369+
// TODO : Calling dirSize() could be expensive for large directories, as it recursively
370370
// walks the entire tree. Consider lazy loading, caching, or an async approach to avoid UI lockups.
371371
m.fileMetaData.metaData = append(m.fileMetaData.metaData, [2]string{"Size", common.FormatFileSize(dirSize(filePath))})
372372
}
@@ -423,7 +423,7 @@ func (m *model) returnMetaData() {
423423
panel.element[panel.cursor].metaData = m.fileMetaData.metaData
424424
}
425425

426-
// Todo : Replace all usage of "m.fileModel.filePanels[m.filePanelFocusIndex]" with this
426+
// TODO : Replace all usage of "m.fileModel.filePanels[m.filePanelFocusIndex]" with this
427427
// There are many usage
428428
func (m *model) getFocusedFilePanel() *filePanel {
429429
return &m.fileModel.filePanels[m.filePanelFocusIndex]

src/internal/handle_file_operation_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func TestCompressSelectedFiles(t *testing.T) {
3333
// 5 - Compress multiple selected files and directories
3434
// 6 - Pressing compress hotkey on empty panel doesn't do anything or crashes on both browser/select mode
3535

36-
// Copied from CopyTest. Todo - work on it.
36+
// Copied from CopyTest. TODO - work on it.
3737

3838
testdata := []struct {
3939
name string
@@ -126,7 +126,7 @@ func TestCompressSelectedFiles(t *testing.T) {
126126
}, time.Second, 10*time.Millisecond)
127127

128128
// No-op update to get the filepanel updated
129-
// Todo - This should not be needed. Only operation finish SPF should refresh
129+
// TODO - This should not be needed. Only operation finish SPF should refresh
130130
// on its own
131131
TeaUpdateWithErrCheck(t, &m, nil)
132132

src/internal/handle_file_operations.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ func (m *model) panelCreateNewFile() {
8282
m.firstTextInput = true
8383
}
8484

85-
// Todo : This function does not needs the entire model. Only pass the panel object
85+
// TODO : This function does not needs the entire model. Only pass the panel object
8686
func (m *model) IsRenamingConflicting() bool {
87-
// Todo : Replace this with m.getCurrentFilePanel() everywhere
87+
// TODO : Replace this with m.getCurrentFilePanel() everywhere
8888
panel := &m.fileModel.filePanels[m.filePanelFocusIndex]
8989

9090
if len(panel.element) == 0 {
@@ -273,7 +273,7 @@ func (m *model) deleteMultipleItems() {
273273
}
274274
}
275275

276-
// This feels a bit fuzzy and unclean. Todo : Review and simplify this.
276+
// This feels a bit fuzzy and unclean. TODO : Review and simplify this.
277277
// We should never get to this condition of panel.cursor getting negative
278278
// and if we do, we should error log that.
279279
if panel.cursor >= len(panel.element)-len(panel.selected)-1 {
@@ -331,7 +331,7 @@ func (m *model) completelyDeleteSingleItem() {
331331
message.processNewState = p
332332
channel <- message
333333
}
334-
// Todo : This is duplicated code fragment. Remove this duplication
334+
// TODO : This is duplicated code fragment. Remove this duplication
335335
if len(panel.element) == 0 {
336336
panel.cursor = 0
337337
} else if panel.cursor >= len(panel.element) {
@@ -496,7 +496,7 @@ func (m *model) pasteItem() {
496496
}
497497

498498
for _, folderPath := range m.copyItems.items {
499-
// Todo : Fix this. This is inefficient
499+
// TODO : Fix this. This is inefficient
500500
// In case of a cut operations for a directory with a lot of files
501501
// we are unnecessarily walking the whole directory recursively
502502
// while os will just perform a rename
@@ -560,7 +560,7 @@ func (m *model) pasteItem() {
560560
if m.copyItems.cut && !isExternalDiskPath(filePath) {
561561
err = moveElement(filePath, filepath.Join(panel.location, filepath.Base(filePath)))
562562
} else {
563-
// Todo : These error cases are hard to test. We have to somehow make the paste operations fail,
563+
// TODO : These error cases are hard to test. We have to somehow make the paste operations fail,
564564
// which is time consuming and manual. We should test these with automated testcases
565565
err = pasteDir(filePath, filepath.Join(panel.location, filepath.Base(filePath)), id, m)
566566
if err != nil {
@@ -594,7 +594,7 @@ func (m *model) pasteItem() {
594594
}
595595

596596
// Extract compressed file
597-
// Todo : err should be returned and properly handled by the caller
597+
// TODO : err should be returned and properly handled by the caller
598598
func (m *model) extractFile() {
599599
var err error
600600
panel := &m.fileModel.filePanels[m.filePanelFocusIndex]

src/internal/handle_panel_movement.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func (panel *filePanel) singleItemSelect() {
170170
// This is inefficient. Once you select 1000 items,
171171
// each select / deselect operation can take 1000 operations
172172
// It can be easily made constant time.
173-
// Todo : (performance)convert panel.selected to a set (map[string]struct{})
173+
// TODO : (performance)convert panel.selected to a set (map[string]struct{})
174174
panel.selected = removeElementByValue(panel.selected, elementLocation)
175175
} else {
176176
panel.selected = append(panel.selected, elementLocation)
@@ -195,7 +195,7 @@ func (m *model) toggleFooterController() {
195195
if err != nil {
196196
slog.Error("Error while updating toggleFooter data", "error", err)
197197
}
198-
// Todo : Revisit this. Is this really need here, is this correct ?
198+
// TODO : Revisit this. Is this really need here, is this correct ?
199199
m.setHeightValues(m.fullHeight)
200200
}
201201

src/internal/handle_panel_navigation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func (m *model) createNewFilePanel(location string) error {
2828
// But we would have len() here as 1. Hence there would be discrepency here.
2929
// Although this is not possible in actual usage, and can be only reproduced in tests.
3030
if len(m.fileModel.filePanels) == m.fileModel.maxFilePanel {
31-
// Todo : Define as a predefined error in errors.go
31+
// TODO : Define as a predefined error in errors.go
3232
return errors.New("maximum panel count reached")
3333
}
3434

0 commit comments

Comments
 (0)