-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
Add editorconfig validation #896
Add editorconfig validation #896
Conversation
📝 WalkthroughWalkthroughThis pull request introduces comprehensive EditorConfig validation functionality to the Atmos CLI. The changes span multiple files, adding a new command Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
With the strength of our collective effort, we have forged a robust validation mechanism! The EditorConfig checker shall bring order and consistency to our codebase, ensuring our files march in perfect formation. 🛡️ Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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
🧹 Nitpick comments (2)
cmd/editor_config.go (2)
37-57
: Initialization flow is well-structured.
MergingcliConfig
intocurrentConfig
is clear. Consider logging the final config path for troubleshooting.🧰 Tools
🪛 golangci-lint (1.62.2)
46-46: printf: non-constant format string in call to github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Error
(govet)
113-137
: Persistent flags are well-defined.
The scope of each flag is clear. If more flags appear, ensure new ones align with this pattern for consistency.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
go.sum
is excluded by!**/*.sum
📒 Files selected for processing (2)
cmd/editor_config.go
(1 hunks)go.mod
(3 hunks)
🧰 Additional context used
🪛 golangci-lint (1.62.2)
cmd/editor_config.go
46-46: printf: non-constant format string in call to github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Error
(govet)
62-62: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Debug
(govet)
77-77: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Error
(govet)
83-83: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Output
(govet)
93-93: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Error
(govet)
103-103: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Output
(govet)
🔇 Additional comments (5)
cmd/editor_config.go (3)
25-35
: Command registration approach looks straightforward.
Nicely integrates with Cobra for CLI usage.
59-98
: Validation logic is robust.
Checks file existence, handles dry-run, and reports errors smoothly. Good job!
🧰 Tools
🪛 golangci-lint (1.62.2)
62-62: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Debug
(govet)
77-77: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Error
(govet)
83-83: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Output
(govet)
93-93: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Error
(govet)
100-111
: Early termination flags are polite and clear.
Helps users see version or usage right away. Nicely done.
🧰 Tools
🪛 golangci-lint (1.62.2)
103-103: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Output
(govet)
go.mod (2)
20-20
: Dependency pinned to v3.0.3.
Looks good. Confirm that it aligns with your tested version.
99-99
: New indirect dependencies recognized.
These libraries are typical for EditorConfig checks. Please confirm their licenses are suitable for your project.
Also applies to: 127-127, 132-132
📝 WalkthroughWalkthroughThis pull request introduces a new CLI command Changes
Assessment against linked issues
Possibly related PRs
Suggested Labels
Suggested Reviewers
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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: 2
🧹 Nitpick comments (1)
cmd/editor_config.go (1)
26-28
: Offer usage examples for the new command.Adding examples in the long description or using
cmd.Example
helps users understand usage quickly.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
go.sum
is excluded by!**/*.sum
📒 Files selected for processing (2)
cmd/editor_config.go
(1 hunks)go.mod
(3 hunks)
🧰 Additional context used
🪛 golangci-lint (1.62.2)
cmd/editor_config.go
46-46: printf: non-constant format string in call to github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Error
(govet)
62-62: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Debug
(govet)
77-77: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Error
(govet)
83-83: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Output
(govet)
93-93: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Error
(govet)
103-103: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Output
(govet)
🔇 Additional comments (1)
go.mod (1)
20-20
: Dependencies look good.
The newly added references appear consistent with the code. No issues detected.
Also applies to: 99-99, 127-127, 132-132
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
♻️ Duplicate comments (1)
cmd/editor_config.go (1)
39-60
:⚠️ Potential issueImprove error handling and logger usage.
The function needs improvements in error handling and logger usage:
- Use proper format strings in logger calls
- Consider returning errors instead of calling os.Exit
Apply these changes to fix the logger format strings and improve error handling:
func initializeConfig() error { u.LogInfo(atmosConfig, fmt.Sprintf("EditorConfig Checker CLI Version: %s", editorConfigVersion)) if configFilePath == "" { configFilePath = defaultConfigFilePath } var err error currentConfig, err = config.NewConfig(configFilePath) if err != nil { - logger.Error(err.Error()) - os.Exit(1) + logger.Errorf("%v", err) + return fmt.Errorf("failed to create config: %w", err) } if err := currentConfig.Parse(); err != nil { + return fmt.Errorf("failed to parse config: %w", err) } if tmpExclude != "" { currentConfig.Exclude = append(currentConfig.Exclude, tmpExclude) } currentConfig.Merge(cliConfig) + return nil }🧰 Tools
🪛 golangci-lint (1.62.2)
49-49: printf: non-constant format string in call to github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Error
(govet)
🧹 Nitpick comments (1)
cmd/editor_config.go (1)
18-25
: Consider encapsulating configuration variables.The global variables could be encapsulated within a configuration struct to improve maintainability and testability.
+type editorConfigState struct { + version string + defaultConfigPath string + currentConfig *config.Config + cliConfig config.Config + configFilePath string + tmpExclude string +} +var state = &editorConfigState{ + version: "v3.0.3", // Update to match dependency version + defaultConfigPath: ".ecrc", +}
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
cmd/editor_config.go
(1 hunks)examples/demo-stacks/.ecrc
(1 hunks)tests/test_cases.yaml
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- examples/demo-stacks/.ecrc
🧰 Additional context used
🪛 golangci-lint (1.62.2)
cmd/editor_config.go
49-49: printf: non-constant format string in call to github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Error
(govet)
80-80: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Error
(govet)
86-86: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Output
(govet)
96-96: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Error
(govet)
107-107: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Output
(govet)
🔇 Additional comments (3)
tests/test_cases.yaml (1)
139-153
: Ensure version string consistency across test and implementation.
The test expects EditorConfig Checker CLI Version "v3.0.0", but the dependency in go.mod uses v3.0.3. This mismatch could cause test failures.
cmd/editor_config.go (2)
27-37
: LGTM! Well-structured command implementation.
The command follows Cobra best practices with clear separation between initialization and execution.
117-134
: LGTM! Well-organized flag configuration.
The flags are comprehensive and well-documented, following Cobra best practices.
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
🧹 Nitpick comments (1)
cmd/editor_config.go (1)
62-101
: Consider refactoring for better testabilityThe function has multiple
os.Exit
calls which makes unit testing difficult. Consider:
- Returning errors instead of calling
os.Exit
- Moving the version check to a separate function
- Centralizing error handling
Here's a suggested refactor pattern:
- func runMainLogic() { + func runMainLogic() error { config := *currentConfig - if utils.FileExists(config.Path) && config.Version != "" && config.Version != editorConfigVersion { - u.LogError(atmosConfig, fmt.Errorf("Version from config file is not the same as the version of the binary")) - u.LogError(atmosConfig, fmt.Errorf("Binary: %s, Config: %s", editorConfigVersion, config.Version)) - os.Exit(1) + if err := checkVersion(config); err != nil { + return fmt.Errorf("version check failed: %w", err) } filePaths, err := files.GetFiles(config) if err != nil { - u.LogError(atmosConfig, err) - os.Exit(1) + return fmt.Errorf("failed to get files: %w", err) } // ... rest of the logic with similar error handling + return nil } + func checkVersion(config config.Config) error { + if !utils.FileExists(config.Path) || config.Version == "" { + return nil + } + if config.Version != editorConfigVersion { + return fmt.Errorf("version mismatch: binary=%s, config=%s", + editorConfigVersion, config.Version) + } + return nil + }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
cmd/editor_config.go
(1 hunks)
🧰 Additional context used
🪛 golangci-lint (1.62.2)
cmd/editor_config.go
106-106: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Output
(govet)
🔇 Additional comments (3)
cmd/editor_config.go (3)
18-18
: Align editorConfigVersion with library version
The hardcoded version v3.0.0
doesn't match the library version v3.0.3
from go.mod. This mismatch could cause confusion during version checks.
- editorConfigVersion = "v3.0.0"
+ editorConfigVersion = "v3.0.3"
26-36
: Well-structured command implementation!
Clean separation of concerns between initialization and execution using Cobra's PreRun and Run hooks.
117-133
: Excellent flag configuration!
The flags are well-documented, comprehensive, and follow a consistent pattern. The granular disable options provide good flexibility for users.
879fb8b
to
3db160d
Compare
… of https://github.com/cloudposse/atmos into feature/dev-2836-implement-atmos-validate-editorconfig
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: 2
🧹 Nitpick comments (1)
cmd/editor_config.go (1)
120-120
: Fix non-constant format string warning.Address the govet warning about non-constant format string:
- config.Logger.Output(editorConfigVersion) + config.Logger.Output("%s", editorConfigVersion)🧰 Tools
🪛 golangci-lint (1.62.2)
120-120: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Output
(govet)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
cmd/editor_config.go
(1 hunks)tests/test_cases.yaml
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- tests/test_cases.yaml
🧰 Additional context used
🪛 golangci-lint (1.62.2)
cmd/editor_config.go
120-120: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Output
(govet)
🔇 Additional comments (3)
cmd/editor_config.go (3)
20-20
: Use the conventional .editorconfig filename.
As suggested in previous feedback, let's use the standard .editorconfig
filename instead of .ecrc
.
- defaultConfigFilePath = ".ecrc"
+ defaultConfigFilePath = ".editorconfig"
28-30
: Update command name and descriptions for clarity.
As suggested in previous feedback:
- Use: "editorconfig-checker",
- Short: "EditorConfig Checker CLI",
- Long: "A command-line tool to check your files against the EditorConfig rules",
+ Use: "editorconfig",
+ Short: "Validate all files against the EditorConfig",
+ Long: "Validate all files against the project's EditorConfig rules",
40-63
: LGTM! Well-structured configuration initialization.
The configuration initialization is well-implemented with proper error handling and logging using Atmos utilities.
… of https://github.com/cloudposse/atmos into feature/dev-2836-implement-atmos-validate-editorconfig
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
🧹 Nitpick comments (2)
cmd/editor_config.go (2)
17-25
: Consider adding documentation for exported variables.Adding documentation for these variables would improve code maintainability and help other developers understand their purpose.
var ( + // editorConfigVersion is the version of the editorconfig-checker being used editorConfigVersion = "v3.0.3" + // defaultConfigFilePath is the default path to look for the .editorconfig file defaultConfigFilePath = ".editorconfig" + // initEditorConfig indicates whether to initialize a new .editorconfig file initEditorConfig bool + // currentConfig holds the current editorconfig configuration currentConfig *config.Config + // cliConfig holds the configuration from command line flags cliConfig config.Config + // configFilePath is the path to the .editorconfig file configFilePath string + // tmpExclude holds temporary exclude patterns from command line tmpExclude string )
69-105
: Consider breaking down the main logic into smaller functions.The
runMainLogic
function handles multiple responsibilities. Consider extracting the file processing and validation logic into separate functions for better maintainability.+func processFiles(config config.Config) ([]string, error) { + filePaths, err := files.GetFiles(config) + if err != nil { + return nil, err + } + return filePaths, nil +} + +func validateFiles(filePaths []string, config config.Config) error { + errors := validation.ProcessValidation(filePaths, config) + errorCount := er.GetErrorCount(errors) + if errorCount != 0 { + er.PrintErrors(errors, config) + return fmt.Errorf("%d errors found", errorCount) + } + return nil +}
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
cmd/editor_config.go
(1 hunks)examples/quick-start-simple/.editorconfig
(1 hunks)tests/test_cases.yaml
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- examples/quick-start-simple/.editorconfig
🚧 Files skipped from review as they are similar to previous changes (1)
- tests/test_cases.yaml
🧰 Additional context used
🪛 golangci-lint (1.62.2)
cmd/editor_config.go
122-122: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Output
(govet)
🔇 Additional comments (3)
cmd/editor_config.go (3)
60-60
: Handle potential Parse() errors.
The error from currentConfig.Parse()
is silently ignored. Consider handling potential parsing errors.
133-150
: Support flag configuration in atmos.yaml.
These flags should be configurable via atmos.yaml for better consistency with other Atmos commands.
122-122
: 🛠️ Refactor suggestion
Use constant format string in logger call.
The logger expects a format string. Use a format string to avoid the "non-constant format string" warning.
- config.Logger.Output(editorConfigVersion)
+ config.Logger.Output("%s", editorConfigVersion)
Likely invalid or redundant comment.
🧰 Tools
🪛 golangci-lint (1.62.2)
122-122: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Output
(govet)
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: 0
🧹 Nitpick comments (1)
cmd/editor_config.go (1)
37-37
: Consider checking the error fromcmd.Help()
While it’s common to ignore the return forcmd.Help()
, static analysis tools flag this as an unhandled error.🧰 Tools
🪛 golangci-lint (1.62.2)
37-37: Error return value of
cmd.Help
is not checked(errcheck)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
cmd/editor_config.go
(1 hunks)pkg/schema/schema.go
(2 hunks)
🧰 Additional context used
📓 Learnings (1)
cmd/editor_config.go (1)
Learnt from: osterman
PR: cloudposse/atmos#740
File: cmd/cmd_utils.go:340-359
Timestamp: 2024-11-12T05:52:05.088Z
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.
🪛 golangci-lint (1.62.2)
cmd/editor_config.go
37-37: Error return value of cmd.Help
is not checked
(errcheck)
173-173: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Output
(govet)
🔇 Additional comments (6)
cmd/editor_config.go (2)
66-66
: Same existing concern about ignoring parsing errors
173-173
: Switch to a constant format string
This logger invocation can raise “non-constant format string” warnings in some lint checks. Consider using a format method (e.g. config.Logger.Outputf("%s", editorConfigVersion)
).
🧰 Tools
🪛 golangci-lint (1.62.2)
173-173: printf: non-constant format string in call to (github.com/editorconfig-checker/editorconfig-checker/v3/pkg/logger.Logger).Output
(govet)
pkg/schema/schema.go (4)
35-35
: Good addition of the Validate
field
The extension of the configuration schema is beneficial. Ensure you have corresponding documentation or comments explaining its usage.
42-44
: Validate
struct creation looks clean
No issues are spotted. This struct helps group editorconfig validation settings neatly.
46-56
: New EditorConfig
struct
Everything appears consistent with the rest of the configuration. If needed, add docstrings for clarity.
58-66
: DisabledChecks
struct is well-defined
This offers a flexible way to toggle checks. Looks good for maintainability.
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: 0
🧹 Nitpick comments (4)
cmd/editor_config.go (4)
19-26
: Consider renamingtmpExclude
for clarity.The variable name
tmpExclude
doesn't clearly convey its purpose as a CLI-provided exclude pattern that gets merged into the configuration.- tmpExclude string + cliExcludePattern string
36-39
: Handle potential Help() error.The
cmd.Help()
function returns an error that should be handled.if cliConfig.Help { - cmd.Help() - os.Exit(0) + if err := cmd.Help(); err != nil { + u.LogErrorAndExit(atmosConfig, err) + } + os.Exit(0) }🧰 Tools
🪛 golangci-lint (1.62.2)
37-37: Error return value of
cmd.Help
is not checked(errcheck)
74-117
: Consider simplifying config replacement logic.The repetitive if-blocks for config replacement could be simplified using reflection or struct field mapping for similar fields, especially in the
Disable
section.Consider extracting the
Disable
field handling into a separate function:func replaceDisableConfig(cliConfig *config.Config, atmosConfig schema.AtmosConfiguration) { disableFields := map[string]struct{ cli *bool atmos bool }{ "TrimTrailingWhitespace": {&cliConfig.Disable.TrimTrailingWhitespace, atmosConfig.Validate.EditorConfig.Disable.TrimTrailingWhitespace}, // ... other fields } for _, field := range disableFields { if field.atmos { *field.cli = field.atmos } } }
146-146
: Remove newline prefix from error message.The error message starts with a newline character, which is unnecessary as the logging framework handles line formatting.
- u.LogErrorAndExit(atmosConfig, fmt.Errorf("\n%d errors found", errorCount)) + u.LogErrorAndExit(atmosConfig, fmt.Errorf("%d errors found", errorCount))
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
cmd/editor_config.go
(1 hunks)examples/quick-start-simple/atmos.yaml
(0 hunks)tests/test_cases.yaml
(1 hunks)
💤 Files with no reviewable changes (1)
- examples/quick-start-simple/atmos.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
- tests/test_cases.yaml
🧰 Additional context used
📓 Learnings (1)
cmd/editor_config.go (1)
Learnt from: osterman
PR: cloudposse/atmos#740
File: cmd/cmd_utils.go:340-359
Timestamp: 2024-11-12T05:52:05.088Z
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.
🪛 golangci-lint (1.62.2)
cmd/editor_config.go
37-37: Error return value of cmd.Help
is not checked
(errcheck)
🔇 Additional comments (4)
cmd/editor_config.go (4)
1-17
: LGTM! Clean import organization.
The imports are well-organized and properly aliased to avoid naming conflicts.
44-72
: LGTM! Solid configuration initialization.
The function follows established error handling patterns and correctly handles configuration initialization.
153-163
: LGTM! Solid version check implementation.
The version check is well-implemented with clear error messages and proper handling of edge cases.
166-182
: Consider previous feedback about flags.
The version flag and atmos.yaml configuration suggestions from previous reviews are still applicable.
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: 0
🧹 Nitpick comments (2)
atmos.yaml (2)
97-111
: Consider adding format validation.The configuration is well-structured with clear documentation. However, the
format
option could benefit from validation to ensure only "default" or "json" are accepted.Consider adding validation in the schema to restrict the format values:
format: type: string enum: ["default", "json"] default: "default"
113-131
: Strong defaults that promote code quality!The disable section is well-structured with all checks enabled by default (disable: false). This is a secure default that encourages consistent code formatting across the team. Each option is clearly documented and provides granular control when needed.
The default configuration (all checks enabled) will help maintain consistent code quality across teams. Consider documenting these defaults in your team's coding standards documentation.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
atmos.yaml
(1 hunks)
🔇 Additional comments (1)
atmos.yaml (1)
94-96
: LGTM! Clean introduction of the validate section.
The section is well-structured and properly documented, following the established pattern in the configuration file.
e43d275
to
ee3a8e5
Compare
ee3a8e5
to
785394e
Compare
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.
LGTM, please address a few comments
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: 0
🧹 Nitpick comments (4)
tests/snapshots/TestCLICommands_atmos_validate_editorconfig_error.stdout.golden (1)
1-3
: Error messages look good, warrior! Consider enhancing clarity.The error message format is clear and includes all necessary information. However, we could make it even more helpful for our fellow developers.
Consider this enhanced error format for better clarity:
- 267: Wrong amount of left-padding spaces(want multiple of 2) + 267: Wrong amount of left-padding spaces (found: <actual>, expected: multiple of 2)This would show the actual number of spaces found, making it easier to identify and fix the issue.
website/docs/cli/commands/validate/validate-editorconfig.mdx (3)
10-28
: Consider adding workflow context.The usage instructions are clear, but developers would benefit from knowing when in their workflow they should run this command (e.g., pre-commit, during CI/CD, etc.).
Consider adding a note like:
This command validates files against the formatting rules defined in your .editorconfig file. + +It's recommended to run this command: +- Before committing changes to ensure consistent formatting +- As part of your CI/CD pipeline to enforce team-wide formatting standards
30-37
: Enhance examples with explanatory comments.The examples would be more helpful with brief explanations of when to use each variation.
Consider updating the examples like this:
```shell atmos validate editorconfig -atmos validate editorconfig --logs-level trace -atmos validate editorconfig --no-color -atmos validate editorconfig --dry-run +# For detailed debugging output +atmos validate editorconfig --logs-level trace +# For CI/CD environments or log parsing +atmos validate editorconfig --no-color +# To preview which files would be checked without making changes +atmos validate editorconfig --dry-run--- `41-57`: **Improve table formatting for better readability.** The table content is comprehensive, but the formatting could be enhanced. Consider these improvements: 1. Align the description column content consistently 2. Add spacing between cells for better readability 3. Group related flags together (e.g., all disable flags) Example of aligned content: ```diff -|`--disable-end-of-line` |Disable end-of-line check (default "false") | |no | -|`--disable-indent-size` |Disable indent size check (default "false") | |no | +|`--disable-end-of-line` |Disable end-of-line check (default "false") | |no | +|`--disable-indent-size` |Disable indent size check (default "false") | |no |
🧰 Tools
🪛 LanguageTool
[typographical] ~44-~44: Consider using typographic quotation marks here.
Context: ... |Disable end-of-line check (default "false") | |no...(EN_QUOTES)
[typographical] ~45-~45: Consider using typographic quotation marks here.
Context: ... |Disable indent size check (default "false") | |no...(EN_QUOTES)
[typographical] ~46-~46: Consider using typographic quotation marks here.
Context: ... |Disable indentation check (default "false")||no| |--disable-insert-final-newline
...(EN_QUOTES)
[typographical] ~47-~47: Consider using typographic quotation marks here.
Context: ... |Disable final newline check (default "false")||no| |--disable-max-line-length
...(EN_QUOTES)
[typographical] ~48-~48: Consider using typographic quotation marks here.
Context: ...|Disable max line length check (default "false")||no| |`--disable-trim-trailing-whitesp...(EN_QUOTES)
[typographical] ~49-~49: Consider using typographic quotation marks here.
Context: ...able trailing whitespace check (default "false")||no| |--dry-run
...(EN_QUOTES)
[typographical] ~50-~50: Consider using typographic quotation marks here.
Context: ...w which files would be checked (default "false")||no| |--exclude string
...(EN_QUOTES)
[typographical] ~52-~52: Consider using typographic quotation marks here.
Context: ...he output format: default, gcc (default "default")||no| |--help
...(EN_QUOTES)
[typographical] ~53-~53: Consider using typographic quotation marks here.
Context: ... |help for editorconfig (default "false")||no| |--ignore-defaults
...(EN_QUOTES)
[typographical] ~54-~54: Consider using typographic quotation marks here.
Context: ... |Ignore default excludes (default "false")||no| |--init
...(EN_QUOTES)
[typographical] ~55-~55: Consider using typographic quotation marks here.
Context: ...eates an initial configuration (default "false")||no| |--no-color
...(EN_QUOTES)
[typographical] ~56-~56: Consider using typographic quotation marks here.
Context: ... |Don't print colors (default "false")||no| |--version
...(EN_QUOTES)
[typographical] ~57-~57: Consider using typographic quotation marks here.
Context: ... |Print the version number (default "false")||no|(EN_QUOTES)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
go.sum
is excluded by!**/*.sum
📒 Files selected for processing (8)
go.mod
(3 hunks)tests/snapshots/TestCLICommands_atmos_describe_config.stdout.golden
(1 hunks)tests/snapshots/TestCLICommands_atmos_describe_config_-f_yaml.stdout.golden
(1 hunks)tests/snapshots/TestCLICommands_atmos_validate_editorconfig.stdout.golden
(1 hunks)tests/snapshots/TestCLICommands_atmos_validate_editorconfig_error.stderr.golden
(1 hunks)tests/snapshots/TestCLICommands_atmos_validate_editorconfig_error.stdout.golden
(1 hunks)tests/test-cases/validate-editorconfig.yaml
(1 hunks)website/docs/cli/commands/validate/validate-editorconfig.mdx
(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- tests/snapshots/TestCLICommands_atmos_validate_editorconfig_error.stderr.golden
- tests/snapshots/TestCLICommands_atmos_validate_editorconfig.stdout.golden
🚧 Files skipped from review as they are similar to previous changes (2)
- go.mod
- tests/test-cases/validate-editorconfig.yaml
🧰 Additional context used
🪛 LanguageTool
website/docs/cli/commands/validate/validate-editorconfig.mdx
[typographical] ~44-~44: Consider using typographic quotation marks here.
Context: ... |Disable end-of-line check (default "false") | |no...
(EN_QUOTES)
[typographical] ~45-~45: Consider using typographic quotation marks here.
Context: ... |Disable indent size check (default "false") | |no...
(EN_QUOTES)
[typographical] ~46-~46: Consider using typographic quotation marks here.
Context: ... |Disable indentation check (default "false")||no| |--disable-insert-final-newline
...
(EN_QUOTES)
[typographical] ~47-~47: Consider using typographic quotation marks here.
Context: ... |Disable final newline check (default "false")||no| |--disable-max-line-length
...
(EN_QUOTES)
[typographical] ~48-~48: Consider using typographic quotation marks here.
Context: ...|Disable max line length check (default "false")||no| |`--disable-trim-trailing-whitesp...
(EN_QUOTES)
[typographical] ~49-~49: Consider using typographic quotation marks here.
Context: ...able trailing whitespace check (default "false")||no| |--dry-run
...
(EN_QUOTES)
[typographical] ~50-~50: Consider using typographic quotation marks here.
Context: ...w which files would be checked (default "false")||no| |--exclude string
...
(EN_QUOTES)
[typographical] ~52-~52: Consider using typographic quotation marks here.
Context: ...he output format: default, gcc (default "default")||no| |--help
...
(EN_QUOTES)
[typographical] ~53-~53: Consider using typographic quotation marks here.
Context: ... |help for editorconfig (default "false")||no| |--ignore-defaults
...
(EN_QUOTES)
[typographical] ~54-~54: Consider using typographic quotation marks here.
Context: ... |Ignore default excludes (default "false")||no| |--init
...
(EN_QUOTES)
[typographical] ~55-~55: Consider using typographic quotation marks here.
Context: ...eates an initial configuration (default "false")||no| |--no-color
...
(EN_QUOTES)
[typographical] ~56-~56: Consider using typographic quotation marks here.
Context: ... |Don't print colors (default "false")||no| |--version
...
(EN_QUOTES)
[typographical] ~57-~57: Consider using typographic quotation marks here.
Context: ... |Print the version number (default "false")||no|
(EN_QUOTES)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: Summary
🔇 Additional comments (4)
website/docs/cli/commands/validate/validate-editorconfig.mdx (1)
1-7
: LGTM! Clear and accurate metadata.The frontmatter metadata is well-structured and the description accurately reflects the command's purpose.
tests/snapshots/TestCLICommands_atmos_describe_config.stdout.golden (1)
139-142
: LGTM! The new validate section is well-structured.The addition of the
validate.editorconfig
configuration follows the established pattern and integrates cleanly with the existing configuration structure.Let's verify that this matches the schema definition:
✅ Verification successful
Warrior's seal of approval! The validate.editorconfig configuration is battle-tested and ready.
The configuration structure perfectly matches the schema definition in
pkg/schema/schema.go
, where theColor
field is properly defined as an optional boolean property. The YAML variant of this configuration exists in the test snapshots, showing consistent implementation across formats.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the validate.editorconfig structure matches the schema definition # Search for the schema definition of the validate section ast-grep --pattern 'type Validate struct { $$$ EditorConfig $_ `$$$` $$$ }' # Search for any other validate.editorconfig configuration examples rg -l '"validate":\s*{.*"editorconfig":'Length of output: 470
Script:
#!/bin/bash # Search for EditorConfig struct definition ast-grep --pattern 'type EditorConfig struct { $$$ }' # Search for validate.editorconfig examples with fixed pattern rg -l '"validate"\s*:\s*\{\s*"editorconfig"' # Alternative search for yaml examples rg -l 'validate:\s*\n\s*editorconfig:'Length of output: 2444
Script:
#!/bin/bash # Search for validate.editorconfig examples with multiline support rg -U -l 'validate:(\s|\n)*editorconfig:' # Also search for JSON examples with more flexible pattern rg -l '"validate".*"editorconfig"' --type jsonLength of output: 168
tests/snapshots/TestCLICommands_atmos_describe_config_-f_yaml.stdout.golden (2)
43-45
: Consider expanding editorconfig validation settings.The new validation section is well-placed at the root level, maintaining consistency with the existing configuration structure. However, based on the PR objectives, the editorconfig validation supports additional settings like
exclude
andignore_defaults
that aren't represented in this snapshot test.Would you like me to propose a more comprehensive validation configuration that includes all supported options? This would help ensure the test covers the full range of configuration possibilities.
45-45
: Verify color setting behavior.The
color: true
setting suggests CLI output colorization. Let's verify this behavior is properly tested.
These changes were released in v1.151.0. |
what
why
references
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Documentation
atmos validate editorconfig
.Configuration
atmos.yaml
with new validation settings..editorconfig
file for consistent code formatting.vendor.yaml
for managing vendor components.Testing