-
-
Notifications
You must be signed in to change notification settings - Fork 136
pass config by ref #1755
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
base: main
Are you sure you want to change the base?
pass config by ref #1755
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1755 +/- ##
==========================================
- Coverage 69.89% 69.87% -0.03%
==========================================
Files 398 398
Lines 36487 36487
==========================================
- Hits 25503 25495 -8
- Misses 8675 8683 +8
Partials 2309 2309
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Warning Rate limit exceeded@osterman has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 47 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughSystematic refactoring converting AtmosConfiguration parameters from value to pointer semantics across markdown utilities and renderer modules. Function signatures updated along with all corresponding call sites in implementations, templates, and tests. No control-flow or behavior changes; only calling convention modifications. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes The refactoring follows a consistent pattern across all files—converting value-based configuration parameters to pointer-based ones. While the scope spans multiple files, the homogeneous nature of changes (repetitive application of the same transformation) makes review straightforward. Key areas requiring attention:
Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
errors/error_funcs_test.go (1)
259-264: Need pointer when calling InitializeMarkdownInitializeMarkdown now accepts *schema.AtmosConfiguration; passing a value here stops the test from compiling. Quick fix: pass &atmosConfig so the build stays green.
- InitializeMarkdown(atmosConfig) + InitializeMarkdown(&atmosConfig)pkg/ui/markdown/renderer.go (1)
247-266: Guard against nil atmosConfig before dereferencingThis helper now receives a pointer and touches
atmosConfig.Settingsright away. If any caller passesnil, we’ll panic before we even reachNewRenderer. Add the same defensive check here so both constructor paths reject nil inputs gracefully.func NewTerminalMarkdownRenderer(atmosConfig *schema.AtmosConfiguration) (*Renderer, error) { + if atmosConfig == nil { + return nil, fmt.Errorf("markdown.NewTerminalMarkdownRenderer: atmos config is nil") + } maxWidth := atmosConfig.Settings.Docs.MaxWidth
🧹 Nitpick comments (1)
errors/error_funcs.go (1)
24-27: Shift InitializeMarkdown to pointer inputThanks for pushing the pointer sweep. Passing
schema.AtmosConfigurationby value here still clones the whole struct before you take its address, so we keep the allocation you’re trying to retire. Please update the signature to accept*schema.AtmosConfigurationand thread the pointer through the existing callers to finish the pass-by-ref change.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (13)
cmd/root.go(1 hunks)errors/error_funcs.go(1 hunks)errors/error_funcs_test.go(2 hunks)internal/tui/templates/help_printer.go(1 hunks)internal/tui/templates/templater.go(2 hunks)internal/tui/utils/utils.go(1 hunks)pkg/telemetry/utils_test.go(4 hunks)pkg/ui/markdown/markdown_test.go(10 hunks)pkg/ui/markdown/renderer.go(3 hunks)pkg/ui/markdown/renderer_test.go(2 hunks)pkg/ui/markdown/styles.go(1 hunks)pkg/utils/markdown_utils.go(1 hunks)pkg/utils/markdown_utils_test.go(6 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
pkg/**/*.go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
Place business logic in pkg rather than in cmd
Files:
pkg/utils/markdown_utils.gopkg/ui/markdown/styles.gopkg/ui/markdown/renderer_test.gopkg/ui/markdown/renderer.gopkg/telemetry/utils_test.gopkg/ui/markdown/markdown_test.gopkg/utils/markdown_utils_test.go
**/*.go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
**/*.go: All code must pass golangci-lint checks
Follow Go error handling idioms and use meaningful error messages
Wrap errors with context using fmt.Errorf("context: %w", err)
Consider custom error types for domain-specific errors
Follow standard Go coding style; run gofmt and goimports
Use snake_case for environment variables
Document complex logic with inline comments
Files:
pkg/utils/markdown_utils.gopkg/ui/markdown/styles.goerrors/error_funcs_test.gopkg/ui/markdown/renderer_test.gopkg/ui/markdown/renderer.gointernal/tui/utils/utils.gopkg/telemetry/utils_test.gointernal/tui/templates/templater.gointernal/tui/templates/help_printer.goerrors/error_funcs.gocmd/root.gopkg/ui/markdown/markdown_test.gopkg/utils/markdown_utils_test.go
**/!(*_test).go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
Document all exported functions, types, and methods with Go doc comments
Files:
pkg/utils/markdown_utils.gopkg/ui/markdown/styles.gopkg/ui/markdown/renderer.gointernal/tui/utils/utils.gointernal/tui/templates/templater.gointernal/tui/templates/help_printer.goerrors/error_funcs.gocmd/root.go
**/*_test.go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
**/*_test.go: Every new feature must include comprehensive unit tests
Test both happy paths and error conditions
Use table-driven tests for multiple scenarios
Files:
errors/error_funcs_test.gopkg/ui/markdown/renderer_test.gopkg/telemetry/utils_test.gopkg/ui/markdown/markdown_test.gopkg/utils/markdown_utils_test.go
cmd/**/*.go
📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)
cmd/**/*.go: Use Cobra's recommended command structure with a root command and subcommands
Implement each CLI command in a separate file under cmd/
Use Viper for managing configuration, environment variables, and flags in the CLI
Keep separation of concerns between CLI interface (cmd) and business logic
Use kebab-case for command-line flags
Provide comprehensive help text for all commands and flags
Include examples in Cobra command help
Use Viper for configuration management; support files, env vars, and flags with precedence flags > env > config > defaults
Follow single responsibility; separate command interface from business logic
Provide meaningful user feedback and include progress indicators for long-running operations
Provide clear error messages to users and troubleshooting hints where appropriate
Files:
cmd/root.go
🧠 Learnings (25)
📓 Common learnings
Learnt from: Listener430
Repo: cloudposse/atmos PR: 934
File: tests/fixtures/scenarios/docs-generate/README.md.gotmpl:99-118
Timestamp: 2025-01-25T03:51:57.689Z
Learning: For the cloudposse/atmos repository, changes to template contents should be handled in dedicated PRs and are typically considered out of scope for PRs focused on other objectives.
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 1466
File: toolchain/http_client_test.go:3-10
Timestamp: 2025-09-10T21:17:55.273Z
Learning: In the cloudposse/atmos repository, imports should never be changed as per samtholiya's coding guidelines.
Learnt from: aknysh
Repo: cloudposse/atmos PR: 944
File: go.mod:206-206
Timestamp: 2025-01-17T00:18:57.769Z
Learning: For indirect dependencies with license compliance issues in the cloudposse/atmos repository, the team prefers to handle them in follow-up PRs rather than blocking the current changes, as these issues often require deeper investigation of the dependency tree.
Learnt from: osterman
Repo: cloudposse/atmos PR: 808
File: pkg/config/config.go:478-483
Timestamp: 2024-12-02T21:26:32.337Z
Learning: In the 'atmos' project, when reviewing Go code like `pkg/config/config.go`, avoid suggesting file size checks after downloading remote configs if such checks aren't implemented elsewhere in the codebase.
Learnt from: aknysh
Repo: cloudposse/atmos PR: 943
File: internal/exec/describe_config.go:37-37
Timestamp: 2025-01-19T23:13:50.429Z
Learning: When reviewing pointer usage with `EvaluateYqExpression`, check if the `atmosConfig` parameter is already a pointer (e.g., when returned by `InitCliConfig`) to avoid suggesting unnecessary address-of operations.
Learnt from: milldr
Repo: cloudposse/atmos PR: 1229
File: internal/exec/workflow_test.go:0-0
Timestamp: 2025-06-02T14:12:02.710Z
Learning: In the atmos codebase, workflow error handling was refactored to use `PrintErrorMarkdown` followed by returning the error instead of `PrintErrorMarkdownAndExit`. This pattern allows proper error testing without the function terminating the process with `os.Exit`, enabling unit tests to assert on error conditions.
📚 Learning: 2025-08-16T23:32:40.412Z
Learnt from: aknysh
Repo: cloudposse/atmos PR: 1405
File: internal/exec/describe_dependents_test.go:455-456
Timestamp: 2025-08-16T23:32:40.412Z
Learning: In the cloudposse/atmos Go codebase, `InitCliConfig` returns a `schema.AtmosConfiguration` value (not a pointer), while `ExecuteDescribeDependents` expects a `*schema.AtmosConfiguration` pointer parameter. Therefore, when passing the result of `InitCliConfig` to `ExecuteDescribeDependents`, use `&atmosConfig` to pass the address of the value.
Applied to files:
pkg/utils/markdown_utils.gopkg/ui/markdown/styles.goerrors/error_funcs_test.gopkg/ui/markdown/renderer_test.gopkg/ui/markdown/renderer.gointernal/tui/utils/utils.gopkg/telemetry/utils_test.gointernal/tui/templates/templater.gointernal/tui/templates/help_printer.goerrors/error_funcs.gocmd/root.gopkg/ui/markdown/markdown_test.gopkg/utils/markdown_utils_test.go
📚 Learning: 2025-08-16T23:33:07.477Z
Learnt from: aknysh
Repo: cloudposse/atmos PR: 1405
File: internal/exec/describe_dependents_test.go:651-652
Timestamp: 2025-08-16T23:33:07.477Z
Learning: In the cloudposse/atmos Go codebase, ExecuteDescribeDependents expects a pointer to AtmosConfiguration (*schema.AtmosConfiguration), so when calling it with a value returned by cfg.InitCliConfig (which returns schema.AtmosConfiguration), the address-of operator (&) is necessary: ExecuteDescribeDependents(&atmosConfig, ...).
Applied to files:
pkg/utils/markdown_utils.goerrors/error_funcs_test.gopkg/ui/markdown/renderer_test.gopkg/ui/markdown/renderer.gointernal/tui/utils/utils.gopkg/telemetry/utils_test.gointernal/tui/templates/templater.gointernal/tui/templates/help_printer.gocmd/root.gopkg/ui/markdown/markdown_test.gopkg/utils/markdown_utils_test.go
📚 Learning: 2025-06-02T14:12:02.710Z
Learnt from: milldr
Repo: cloudposse/atmos PR: 1229
File: internal/exec/workflow_test.go:0-0
Timestamp: 2025-06-02T14:12:02.710Z
Learning: In the atmos codebase, workflow error handling was refactored to use `PrintErrorMarkdown` followed by returning the error instead of `PrintErrorMarkdownAndExit`. This pattern allows proper error testing without the function terminating the process with `os.Exit`, enabling unit tests to assert on error conditions.
Applied to files:
pkg/utils/markdown_utils.goerrors/error_funcs_test.gopkg/telemetry/utils_test.gointernal/tui/templates/templater.gointernal/tui/templates/help_printer.goerrors/error_funcs.gocmd/root.gopkg/ui/markdown/markdown_test.gopkg/utils/markdown_utils_test.go
📚 Learning: 2024-10-23T21:36:40.262Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 740
File: cmd/cmd_utils.go:340-359
Timestamp: 2024-10-23T21:36:40.262Z
Learning: In the Go codebase for Atmos, when reviewing functions like `checkAtmosConfig` in `cmd/cmd_utils.go`, avoid suggesting refactoring to return errors instead of calling `os.Exit` if such changes would significantly increase the scope due to the need to update multiple call sites.
Applied to files:
pkg/ui/markdown/styles.goerrors/error_funcs_test.gopkg/ui/markdown/renderer.gointernal/tui/utils/utils.gopkg/telemetry/utils_test.gointernal/tui/templates/templater.gointernal/tui/templates/help_printer.goerrors/error_funcs.gocmd/root.gopkg/ui/markdown/markdown_test.gopkg/utils/markdown_utils_test.go
📚 Learning: 2024-12-02T21:26:32.337Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 808
File: pkg/config/config.go:478-483
Timestamp: 2024-12-02T21:26:32.337Z
Learning: In the 'atmos' project, when reviewing Go code like `pkg/config/config.go`, avoid suggesting file size checks after downloading remote configs if such checks aren't implemented elsewhere in the codebase.
Applied to files:
pkg/ui/markdown/styles.goerrors/error_funcs_test.gocmd/root.gopkg/ui/markdown/markdown_test.gopkg/utils/markdown_utils_test.go
📚 Learning: 2025-06-02T14:12:02.710Z
Learnt from: milldr
Repo: cloudposse/atmos PR: 1229
File: internal/exec/workflow_test.go:0-0
Timestamp: 2025-06-02T14:12:02.710Z
Learning: In the atmos codebase, workflow error handling was refactored to use `PrintErrorMarkdown` followed by returning specific error variables (like `ErrWorkflowNoSteps`, `ErrInvalidFromStep`, `ErrInvalidWorkflowStepType`, `ErrWorkflowStepFailed`) instead of `PrintErrorMarkdownAndExit`. This pattern allows proper error testing without the function terminating the process with `os.Exit`, enabling unit tests to assert on error conditions while maintaining excellent user-facing error formatting.
Applied to files:
errors/error_funcs_test.gopkg/telemetry/utils_test.goerrors/error_funcs.gopkg/ui/markdown/markdown_test.gopkg/utils/markdown_utils_test.go
📚 Learning: 2024-12-12T15:17:45.245Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 808
File: examples/demo-atmos.d/atmos.d/tools/helmfile.yml:10-10
Timestamp: 2024-12-12T15:17:45.245Z
Learning: In `examples/demo-atmos.d/atmos.d/tools/helmfile.yml`, when suggesting changes to `kubeconfig_path`, ensure that the values use valid Go template syntax.
Applied to files:
errors/error_funcs_test.gointernal/tui/templates/templater.gointernal/tui/templates/help_printer.go
📚 Learning: 2025-09-13T18:06:07.674Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 1466
File: toolchain/list.go:39-42
Timestamp: 2025-09-13T18:06:07.674Z
Learning: In the cloudposse/atmos repository, for UI messages in the toolchain package, use utils.PrintfMessageToTUI instead of log.Error or fmt.Fprintln(os.Stderr, ...). Import pkg/utils with alias "u" to follow the established pattern.
Applied to files:
errors/error_funcs_test.gocmd/root.gopkg/ui/markdown/markdown_test.gopkg/utils/markdown_utils_test.go
📚 Learning: 2024-12-07T16:16:13.038Z
Learnt from: Listener430
Repo: cloudposse/atmos PR: 825
File: internal/exec/helmfile_generate_varfile.go:28-31
Timestamp: 2024-12-07T16:16:13.038Z
Learning: In `internal/exec/helmfile_generate_varfile.go`, the `--help` command (`./atmos helmfile generate varfile --help`) works correctly without requiring stack configurations, and the only change needed was to make `ProcessCommandLineArgs` exportable by capitalizing its name.
Applied to files:
errors/error_funcs_test.gointernal/tui/templates/templater.gointernal/tui/templates/help_printer.gocmd/root.go
📚 Learning: 2025-02-03T06:00:11.419Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 959
File: cmd/describe_config.go:20-20
Timestamp: 2025-02-03T06:00:11.419Z
Learning: Commands should use `PrintErrorMarkdownAndExit` with empty title and suggestion (`"", err, ""`) for general error handling. Specific titles like "Invalid Usage" or "File Not Found" should only be used for validation or specific error scenarios.
Applied to files:
errors/error_funcs_test.gointernal/tui/templates/templater.gointernal/tui/templates/help_printer.go
📚 Learning: 2025-02-03T06:00:11.419Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 959
File: cmd/describe_config.go:20-20
Timestamp: 2025-02-03T06:00:11.419Z
Learning: The `describe config` command should use `PrintErrorMarkdownAndExit` with empty title and suggestion for consistency with other commands.
Applied to files:
errors/error_funcs_test.gointernal/tui/templates/templater.go
📚 Learning: 2025-09-23T02:30:42.362Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to **/*_test.go : Use table-driven tests for multiple scenarios
Applied to files:
pkg/ui/markdown/renderer_test.gopkg/ui/markdown/markdown_test.gopkg/utils/markdown_utils_test.go
📚 Learning: 2025-09-13T16:39:20.007Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 1466
File: cmd/markdown/atmos_toolchain_aliases.md:2-4
Timestamp: 2025-09-13T16:39:20.007Z
Learning: In the cloudposse/atmos repository, CLI documentation files in cmd/markdown/ follow a specific format that uses " $ atmos command" (with leading space and dollar sign prompt) in code blocks. This is the established project convention and should not be changed to comply with standard markdownlint rules MD040 and MD014.
Applied to files:
internal/tui/templates/templater.gocmd/root.gopkg/utils/markdown_utils_test.go
📚 Learning: 2025-01-07T20:38:09.618Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 896
File: cmd/editor_config.go:37-40
Timestamp: 2025-01-07T20:38:09.618Z
Learning: Error handling suggestion for `cmd.Help()` in `cmd/editor_config.go` was deferred as the code is planned for future modifications.
Applied to files:
internal/tui/templates/templater.go
📚 Learning: 2025-09-23T02:30:42.362Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to cmd/**/*.go : Include examples in Cobra command help
Applied to files:
internal/tui/templates/templater.go
📚 Learning: 2025-09-23T02:30:42.362Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to cmd/**/*.go : Provide comprehensive help text for all commands and flags
Applied to files:
internal/tui/templates/templater.go
📚 Learning: 2025-01-30T19:30:59.120Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 959
File: cmd/workflow.go:74-74
Timestamp: 2025-01-30T19:30:59.120Z
Learning: Error handling for `cmd.Usage()` is not required in the Atmos CLI codebase, as confirmed by the maintainer.
Applied to files:
internal/tui/templates/templater.go
📚 Learning: 2024-10-20T13:12:46.499Z
Learnt from: haitham911
Repo: cloudposse/atmos PR: 736
File: pkg/config/const.go:6-6
Timestamp: 2024-10-20T13:12:46.499Z
Learning: In `cmd/cmd_utils.go`, it's acceptable to have hardcoded references to `atmos.yaml` in logs, and it's not necessary to update them to use the `CliConfigFileName` constant.
Applied to files:
cmd/root.go
📚 Learning: 2024-12-11T18:40:12.808Z
Learnt from: Listener430
Repo: cloudposse/atmos PR: 844
File: cmd/helmfile.go:37-37
Timestamp: 2024-12-11T18:40:12.808Z
Learning: In the atmos project, `cliConfig` is initialized within the `cmd` package in `root.go` and can be used in other command files.
Applied to files:
cmd/root.go
📚 Learning: 2024-12-13T15:28:13.630Z
Learnt from: Listener430
Repo: cloudposse/atmos PR: 844
File: cmd/version.go:34-44
Timestamp: 2024-12-13T15:28:13.630Z
Learning: In `cmd/version.go`, when handling the `--check` flag in the `versionCmd`, avoid using `CheckForAtmosUpdateAndPrintMessage(cliConfig)` as it updates the cache timestamp, which may not be desired in this context.
Applied to files:
cmd/root.go
📚 Learning: 2025-02-06T13:38:07.216Z
Learnt from: Listener430
Repo: cloudposse/atmos PR: 984
File: internal/exec/copy_glob.go:0-0
Timestamp: 2025-02-06T13:38:07.216Z
Learning: The `u.LogTrace` function in the `cloudposse/atmos` repository accepts `atmosConfig` as its first parameter, followed by the message string.
Applied to files:
cmd/root.go
📚 Learning: 2025-09-23T02:30:42.362Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to **/*_test.go : Test both happy paths and error conditions
Applied to files:
pkg/ui/markdown/markdown_test.gopkg/utils/markdown_utils_test.go
📚 Learning: 2025-08-15T14:43:41.030Z
Learnt from: aknysh
Repo: cloudposse/atmos PR: 1352
File: pkg/store/artifactory_store_test.go:108-113
Timestamp: 2025-08-15T14:43:41.030Z
Learning: In test files for the atmos project, it's acceptable to ignore errors from os.Setenv/Unsetenv operations during test environment setup and teardown, as these are controlled test scenarios.
Applied to files:
pkg/ui/markdown/markdown_test.go
📚 Learning: 2025-02-05T20:16:24.036Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 959
File: pkg/ui/markdown/renderer.go:75-75
Timestamp: 2025-02-05T20:16:24.036Z
Learning: The Purple constant for markdown rendering is defined in pkg/ui/markdown/colors.go.
Applied to files:
pkg/utils/markdown_utils_test.go
🧬 Code graph analysis (13)
pkg/utils/markdown_utils.go (3)
errors/error_funcs.go (1)
InitializeMarkdown(24-30)pkg/schema/schema.go (1)
AtmosConfiguration(27-65)pkg/perf/perf.go (1)
Track(121-138)
pkg/ui/markdown/styles.go (1)
pkg/schema/schema.go (1)
AtmosConfiguration(27-65)
errors/error_funcs_test.go (2)
pkg/ui/markdown/renderer.go (1)
NewTerminalMarkdownRenderer(247-267)pkg/schema/schema.go (1)
AtmosConfiguration(27-65)
pkg/ui/markdown/renderer_test.go (2)
pkg/ui/markdown/renderer.go (1)
NewRenderer(29-78)pkg/schema/schema.go (1)
AtmosConfiguration(27-65)
pkg/ui/markdown/renderer.go (2)
pkg/schema/schema.go (1)
AtmosConfiguration(27-65)pkg/ui/markdown/styles.go (1)
GetDefaultStyle(24-90)
internal/tui/utils/utils.go (2)
pkg/ui/markdown/styles.go (1)
GetDefaultStyle(24-90)pkg/schema/schema.go (1)
AtmosConfiguration(27-65)
pkg/telemetry/utils_test.go (2)
pkg/utils/markdown_utils.go (1)
InitializeMarkdown(96-104)pkg/schema/schema.go (1)
AtmosConfiguration(27-65)
internal/tui/templates/templater.go (2)
pkg/ui/markdown/renderer.go (1)
NewTerminalMarkdownRenderer(247-267)pkg/schema/schema.go (1)
AtmosConfiguration(27-65)
internal/tui/templates/help_printer.go (2)
pkg/ui/markdown/renderer.go (1)
NewTerminalMarkdownRenderer(247-267)pkg/schema/schema.go (1)
AtmosConfiguration(27-65)
errors/error_funcs.go (1)
pkg/ui/markdown/renderer.go (1)
NewTerminalMarkdownRenderer(247-267)
cmd/root.go (2)
errors/error_funcs.go (1)
InitializeMarkdown(24-30)pkg/utils/markdown_utils.go (1)
InitializeMarkdown(96-104)
pkg/ui/markdown/markdown_test.go (3)
pkg/ui/markdown/renderer.go (2)
NewRenderer(29-78)NewTerminalMarkdownRenderer(247-267)pkg/schema/schema.go (1)
AtmosConfiguration(27-65)pkg/ui/markdown/styles.go (1)
GetDefaultStyle(24-90)
pkg/utils/markdown_utils_test.go (4)
pkg/ui/markdown/renderer.go (1)
NewTerminalMarkdownRenderer(247-267)pkg/schema/schema.go (1)
AtmosConfiguration(27-65)errors/error_funcs.go (1)
InitializeMarkdown(24-30)pkg/utils/markdown_utils.go (1)
InitializeMarkdown(96-104)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Summary
| func NewRenderer(atmosConfig *schema.AtmosConfiguration, opts ...Option) (*Renderer, error) { | ||
| r := &Renderer{ | ||
| width: defaultWidth, // default width | ||
| profile: termenv.ColorProfile(), // default color profile | ||
| isTTYSupportForStdout: term.IsTTYSupportForStdout, | ||
| isTTYSupportForStderr: term.IsTTYSupportForStderr, | ||
| atmosConfig: &atmosConfig, | ||
| atmosConfig: atmosConfig, | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prevent nil atmosConfig panics in constructor
Switching this parameter to a pointer means callers can now pass nil. We dereference atmosConfig immediately, so a nil value will panic—something that couldn’t happen when the argument was passed by value. Please short-circuit with a descriptive error before the first dereference. This keeps the new API shape safe and makes the regression testable.
func NewRenderer(atmosConfig *schema.AtmosConfiguration, opts ...Option) (*Renderer, error) {
+ if atmosConfig == nil {
+ return nil, fmt.Errorf("markdown.NewRenderer: atmos config is nil")
+ }
r := &Renderer{
width: defaultWidth, // default width
profile: termenv.ColorProfile(), // default color profile📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| func NewRenderer(atmosConfig *schema.AtmosConfiguration, opts ...Option) (*Renderer, error) { | |
| r := &Renderer{ | |
| width: defaultWidth, // default width | |
| profile: termenv.ColorProfile(), // default color profile | |
| isTTYSupportForStdout: term.IsTTYSupportForStdout, | |
| isTTYSupportForStderr: term.IsTTYSupportForStderr, | |
| atmosConfig: &atmosConfig, | |
| atmosConfig: atmosConfig, | |
| } | |
| func NewRenderer(atmosConfig *schema.AtmosConfiguration, opts ...Option) (*Renderer, error) { | |
| if atmosConfig == nil { | |
| return nil, fmt.Errorf("markdown.NewRenderer: atmos config is nil") | |
| } | |
| r := &Renderer{ | |
| width: defaultWidth, // default width | |
| profile: termenv.ColorProfile(), // default color profile | |
| isTTYSupportForStdout: term.IsTTYSupportForStdout, | |
| isTTYSupportForStderr: term.IsTTYSupportForStderr, | |
| atmosConfig: atmosConfig, | |
| } |
🤖 Prompt for AI Agents
In pkg/ui/markdown/renderer.go around lines 29 to 36, the NewRenderer
constructor now accepts a pointer but immediately dereferences atmosConfig which
will panic if callers pass nil; add an early nil check at the top of NewRenderer
that returns a descriptive error (e.g., return nil, fmt.Errorf("atmosConfig is
required") or errors.New("...")) before any dereference, so the function
short-circuits safely and the regression can be tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samtholiya please address this ☝️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!
|
💥 This pull request now has conflicts. Could you fix it @samtholiya? 🙏 |
what
why
references
#1619
Summary by CodeRabbit
Refactor
Tests