Describe the bug
CLI Code Quality and Logic Issues
Summary
While reviewing the CLI codebase, several issues were identified that affect compilation, code readability, and runtime behavior. These issues include function name typos and a logic bug related to file path normalization.
Issue 1: Typo in Command Constructor Function
Severity
🔴 Critical – Causes compilation error
Description
The function responsible for creating the CLI command is misspelled as NewCommad().
Because of this typo, the function cannot be resolved correctly, leading to a compilation error when referenced elsewhere in the code.
Location
Definition: cmd/cmd.go (Line 25)
Usage: main.go (Line 11)
Current Code
// cmd/cmd.go
func NewCommad() *cobra.Command {
// ...
}
// main.go
command := cmd.NewCommad()
Expected Code
// cmd/cmd.go
func NewCommand() *cobra.Command {
// ...
}
// main.go
command := cmd.NewCommand()
Error Message
Suggested Fix
Rename the function and update all references from:
to
Issue 2: Typo in WatchManager Constructor
Severity
🔴 Critical – Naming inconsistency
Description
The constructor for WatchManager is misspelled as NewWatchManger().
Although the code compiles because the same typo is used everywhere, it creates confusion and does not match the struct name.
Locations
Definition: pkg/watcher/watchManager.go
Usage: cmd/import.go
Usage: watcher/main.go
Current Code
func NewWatchManger(configPath string) (*WatchManager, error) {
// ...
}
Expected Code
func NewWatchManager(configPath string) (*WatchManager, error) {
// ...
}
Impact
Suggested Fix
Rename the function and update all call sites from:
to
Issue 3: File Path Normalization Happens Too Late
Severity
🟡 High – Logic bug
Description
The import command normalizes the file path (removing ./) after calling UploadArtifact().
This creates inconsistencies between:
As a result, the file watcher may fail to detect file changes.
Location
cmd/import.go
Current Code
msg, err := mc.UploadArtifact(f, mainArtifact)
if watch {
if strings.HasPrefix(f, "./") {
f = strings.TrimPrefix(f, "./")
}
watchCfg.UpsertEntry(config.WatchEntry{
FilePath: f,
})
}
Problem
Example scenario:
Uploaded artifact path
Watcher path
This mismatch can cause watcher failures.
Expected Behavior
File path normalization should happen before the upload operation so both components use the same path.
Expected Code
if strings.HasPrefix(f, "./") {
f = strings.TrimPrefix(f, "./")
}
msg, err := mc.UploadArtifact(f, mainArtifact)
if watch {
watchCfg.UpsertEntry(config.WatchEntry{
FilePath: f,
})
}
Impact
File watcher may miss change events
Watch mode may silently fail
Inconsistent path handling
Proposed Fix Summary
| Issue |
Type |
Severity |
| NewCommad() typo |
Naming bug |
🔴 Critical |
| NewWatchManger() typo |
Naming bug |
🔴 Critical |
| File path normalization order |
Logic bug |
🟡 High |
Conclusion
Fixing these issues will:
Resolve compilation failures
Improve code readability and consistency
Ensure reliable file watcher behavior in watch mode
Expected behavior
No response
Actual behavior
No response
How to Reproduce?
No response
Microcks version or git rev
No response
Install method (docker-compose, helm chart, operator, docker-desktop extension,...)
No response
Additional information
No response
Describe the bug
CLI Code Quality and Logic Issues
Summary
While reviewing the CLI codebase, several issues were identified that affect compilation, code readability, and runtime behavior. These issues include function name typos and a logic bug related to file path normalization.
Issue 1: Typo in Command Constructor Function
Severity
🔴 Critical – Causes compilation error
Description
The function responsible for creating the CLI command is misspelled as
NewCommad().Because of this typo, the function cannot be resolved correctly, leading to a compilation error when referenced elsewhere in the code.
Location
Definition:
cmd/cmd.go(Line 25)Usage:
main.go(Line 11)Current Code
Expected Code
Error Message
Suggested Fix
Rename the function and update all references from:
to
Issue 2: Typo in WatchManager Constructor
Severity
🔴 Critical – Naming inconsistency
Description
The constructor for
WatchManageris misspelled asNewWatchManger().Although the code compiles because the same typo is used everywhere, it creates confusion and does not match the struct name.
Locations
Definition:
pkg/watcher/watchManager.goUsage:
cmd/import.goUsage:
watcher/main.goCurrent Code
Expected Code
Impact
Poor code readability
Naming inconsistency
Confusion for contributors
Suggested Fix
Rename the function and update all call sites from:
to
Issue 3: File Path Normalization Happens Too Late
Severity
🟡 High – Logic bug
Description
The
importcommand normalizes the file path (removing./) after callingUploadArtifact().This creates inconsistencies between:
the uploaded artifact path
the watcher configuration path
As a result, the file watcher may fail to detect file changes.
Location
cmd/import.goCurrent Code
Problem
Example scenario:
Uploaded artifact path
Watcher path
This mismatch can cause watcher failures.
Expected Behavior
File path normalization should happen before the upload operation so both components use the same path.
Expected Code
Impact
File watcher may miss change events
Watch mode may silently fail
Inconsistent path handling
Proposed Fix Summary
Conclusion
Fixing these issues will:
Resolve compilation failures
Improve code readability and consistency
Ensure reliable file watcher behavior in watch mode
Expected behavior
No response
Actual behavior
No response
How to Reproduce?
No response
Microcks version or git rev
No response
Install method (
docker-compose,helm chart,operator,docker-desktop extension,...)No response
Additional information
No response