databricks-cli/libs/env
Denis Bilenko 8d5351c1c3
Enable errcheck everywhere and fix or silent remaining issues (#1987)
## Changes
Enable errcheck linter for the whole codebase.

Fix remaining complaints:
- If we can propagate error to caller, do that
- If we writing to stdout, continue ignoring errors (to avoid crashing
in "cli | head" case)
- Add exception for cobra non-critical API such as
MarkHidden/MarkDeprecated/RegisterFlagCompletionFunc. This keeps current
code and behaviour, to be decided later if we want to change this.
- Continue ignoring errors where that is desired behaviour (e.g.
git.loadConfig).
- Continue ignoring errors where panicking seems riskier than ignoring
the error.
- Annotate cases in libs/dyn with //nolint:errcheck - to be addressed
later.

Note, this PR is not meant to come up with the best strategy for each
case, but to be a relative safe change to enable errcheck linter.
  
## Tests
Existing tests.
2024-12-11 13:26:00 +01:00
..
context.go Fix `panic: $HOME is not set` (#1027) 2023-11-29 19:08:27 +00:00
context_test.go Fix `panic: $HOME is not set` (#1027) 2023-11-29 19:08:27 +00:00
loader.go Enable errcheck everywhere and fix or silent remaining issues (#1987) 2024-12-11 13:26:00 +01:00
loader_test.go Added `env.UserHomeDir(ctx)` for parallel-friendly tests (#955) 2023-11-08 14:50:20 +00:00
pkg.go Consolidate environment variable interaction (#747) 2023-09-11 08:18:43 +00:00