8000 Support the `--config` flag as an array of strings for `atmos validate editorconfig` by samtholiya · Pull Request #1173 · cloudposse/atmos · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support the --config flag as an array of strings for atmos validate editorconfig #1173

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

Merged
merged 12 commits into from
Apr 1, 2025

Conversation

samtholiya
Copy link
Collaborator
@samtholiya samtholiya commented Mar 28, 2025

what

  • Support the --config flag as an array of strings for atmos validate editorconfig

why

references

Summary by CodeRabbit

  • New Features

    • The application now accepts multiple configuration file paths, offering enhanced flexibility for managing various setups and ensuring a smoother user experience. These enhancements support advanced configuration scenarios and simplify management for diverse project requirements.
  • Documentation

    • The command-line help and documentation have been updated to reflect the new functionality, including clear instructions and default settings for configuration files, ensuring users can easily customize their environment.

@samtholiya samtholiya force-pushed the feature/dev-3111-update-the-config-flag-in-editorconfig branch from 8ed4af5 to 2d34d25 Compare March 28, 2025 20:35
Copy link
codecov bot commented Mar 28, 2025

Codecov Report

Attention: Patch coverage is 42.85714% with 4 lines in your changes missing coverage. Please review.

Project coverage is 28.34%. Comparing base (1283f07) to head (c25c905).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/validate_editorconfig.go 42.85% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1173      +/-   ##
==========================================
+ Coverage   28.29%   28.34%   +0.05%     
==========================================
  Files         182      182              
  Lines       21284    21284              
==========================================
+ Hits         6022     6034      +12     
+ Misses      14312    14280      -32     
- Partials      950      970      +20     
Flag Coverage Δ
unittests 28.34% <42.85%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@samtholiya samtholiya added the minor New features that do not break anything label Mar 28, 2025
@samtholiya samtholiya marked this pull request as ready for review March 28, 2025 21:37
@samtholiya samtholiya requested a review from a team as a code owner March 28, 2025 21:37
Copy link
Contributor
coderabbitai bot commented Mar 28, 2025
📝 Walkthrough

Walkthrough

The changes update configuration file path handling from a single string to multiple strings. Modifications occur in the core command handling, schema definitions, CLI flag documentation, and testing. The persistent flag now accepts a slice of strings with defined defaults, and related functions have been adjusted to support multiple configuration file paths.

Changes

Files Change Summary
cmd/validate_editorconfig.go
pkg/schema/schema.go
Replaced single string config file path with a slice of strings. Updated variable declarations, function logic (initializeConfig, replaceAtmosConfigInConfig), and persistent flag registration.
tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden
tests/snapshots/TestCLICommands_atmos_validate_editorconfig_help.stdout.golden
Modified CLI documentation to show that the --config flag now accepts multiple values (stringSlice) with a default list of configuration files.
cmd/validate_editorconfig_test.go Added a new test function TestInitConfig to validate the configuration initialization for the editorconfig command.

Sequence Diagram(s)

sequenceDiagram
    participant User as CLI User
    participant Cmd as ValidateEditorconfig Command
    participant Config as Configuration Handler
    participant Schema as EditorConfig Schema

    User->>Cmd: Provide --config flag values
    Cmd->>Config: Call initializeConfig()
    alt ConfigFilePaths provided
        Config->>Config: Append provided values to configPaths
    else
        Config->>Config: Append default config file names to configPaths
    end
    Config->>Schema: Pass configPaths to EditorConfig struct
    Schema-->>Cmd: Return updated configuration
    Cmd-->>User: Execute editorconfig validation with new paths
Loading

Assessment against linked issues

Objective Addressed Explanation
Update the config flag in editorconfig to accept an array of configuration paths [DEV-3111]

Possibly related PRs

Suggested labels

minor

Suggested reviewers

  • osterman

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 628b56a and a587f45.

📒 Files selected for processing (2)
  • tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden (2 hunks)
  • tests/snapshots/TestCLICommands_atmos_validate_editorconfig_help.stdout.golden (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden
  • tests/snapshots/TestCLICommands_atmos_validate_editorconfig_help.stdout.golden
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Build (macos-latest, macos)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: Build (ubuntu-latest, linux)
  • GitHub Check: Lint (golangci)
  • GitHub Check: website-deploy-preview
  • GitHub Check: Analyze (go)
  • GitHub Check: Summary

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or @auto-summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @auto-title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor
@coderabbitai coderabbitai bot left a 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/validate_editorconfig.go (1)

78-80: Consider adding explicit nil check for ConfigFilePaths.

While checking length works for nil slices in Go, adding an explicit nil check would improve code clarity and prevent potential issues if implementation details change in the future.

-	if !cmd.Flags().Changed("config") && len(atmosConfig.Validate.EditorConfig.ConfigFilePaths) > 0 {
+	if !cmd.Flags().Changed("config") && atmosConfig.Validate.EditorConfig.ConfigFilePaths != nil && len(atmosConfig.Validate.EditorConfig.ConfigFilePaths) > 0 {
 		configFilePaths = atmosConfig.Validate.EditorConfig.ConfigFilePaths
 	}
🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 79-79: cmd/validate_editorconfig.go#L79
Added line #L79 was not covered by tests

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 723a0c3 and 46060f4.

📒 Files selected for processing (5)
  • cmd/validate_editorconfig.go (4 hunks)
  • cmd/validate_editorconfig_test.go (1 hunks)
  • pkg/schema/schema.go (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden (1 hunks)
  • tests/snap 8000 shots/TestCLICommands_atmos_validate_editorconfig_help.stdout.golden (1 hunks)
🧰 Additional context used
🪛 GitHub Check: codecov/patch
cmd/validate_editorconfig.go

[warning] 54-54: cmd/validate_editorconfig.go#L54
Added line #L54 was not covered by tests


[warning] 79-79: cmd/validate_editorconfig.go#L79
Added line #L79 was not covered by tests

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Summary
🔇 Additional comments (7)
cmd/validate_editorconfig_test.go (1)

5-12: Good addition of a test function for config initialization.

This test ensures the initializeConfig function works with the editorConfigCmd. The comments clearly explain why this test is minimal and reference ticket DEV-3094 for future test coverage improvements.

pkg/schema/schema.go (1)

173-177: Proper update from single config to multiple configs.

The field has been appropriately changed from ConfigFilePath string to ConfigFilePaths []string while maintaining the same struct tags. This change aligns with the PR's objective to support an array of strings for editorconfig configuration.

tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden (1)

11-13: Help text correctly updated to show stringSlice type with defaults.

The help text now accurately reflects that the --config flag accepts multiple values (stringSlice) with appropriate default values. This ensures users understand the new capability to specify multiple configuration files.

tests/snapshots/TestCLICommands_atmos_validate_editorconfig_help.stdout.golden (1)

11-13: Help text correctly updated to show stringSlice type with defaults.

The help text for this alternative command format has been consistently updated to reflect the new --config flag type and default values, maintaining uniformity across the CLI documentation.

cmd/validate_editorconfig.go (3)

27-27: Variable type updated to support multiple config files.

This change correctly updates the configFilePath variable from a string to a slice of strings, aligning with the PR's objective to support an array of strings for editorconfig validation.


182-182: Flag updated to accept multiple configuration paths.

The StringSliceVar correctly replaces StringVar, and defaultConfigFileNames is appropriately used as the default value. This change maintains backward compatibility while supporting the new functionality.


53-57:

❓ Verification inconclusive

Initialization logic updated for multiple config files.

The logic correctly handles both cases - when configFilePaths is empty (using defaults) and when it contains paths (using provided values). This ensures backward compatibility while supporting the new array structure.


🏁 Script executed:

#!/bin/bash
# Verify test coverage for this code segment
grep -r "func TestInitialize" cmd/

Length of output: 36


Action: Verify test coverage for editorconfig initialization logic

The updated initialization code in cmd/validate_editorconfig.go (lines 53–57) correctly handles both empty and non-empty configFilePaths by respectively appending the default configuration names or the provided paths. This logic appropriately maintains backward compatibility while extending functionality.

However, our recent verification attempt using:

grep -r "func TestInitialize" cmd/

did not yield any output. 
Please verify manually or add tests to ensure that:

  • The default configuration branch (when configFilePaths is empty) is adequately tested.
  • The provided configuration branch (when configFilePaths is non-empty) is covered by tests.

If tests already exist under a different name (e.g., TestValidateEditorConfig), please confirm they comprehensively handle both cases. Otherwise, consider adding these tests.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 54-54: cmd/validate_editorconfig.go#L54
Added line #L54 was not covered by tests

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 28, 2025
@aknysh aknysh added no-release Do not create a new release (wait for additional code changes) and removed minor New features that do not break anything labels Mar 30, 2025
Copy link
Member
@aknysh aknysh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samtholiya please address a few comments

also, please update the docs https://atmos.tools/cli/commands/validate/editorconfig/

Co-authored-by: Andriy Knysh <aknysh@users.noreply.github.com>
Co-authored-by: Andriy Knysh <aknysh@users.noreply.github.com>
coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 31, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 31, 2025
Copy link
Contributor
@coderabbitai coderabbitai bot left a 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)
website/docs/cli/commands/validate/validate-editorconfig.mdx (1)

41-57: Optional: Use Typographic Quotes for Improved Readability: Static analysis suggests replacing the plain quotes around the default file names (".editorconfig", ".editorconfig-checker.json", ".ecrc") with typographic quotation marks. This is a minor nitpick that could enhance the visual polish of the documentation.

🧰 Tools
🪛 LanguageTool

[typographical] ~43-~43: Consider using a typographic opening quote here.
Context: ...ath to the configuration file (default: ".editorconfig", ".editorconfig-checker.j...

(EN_QUOTES)


[typographical] ~43-~43: Consider using a typographic close quote here.
Context: ...figuration file (default: ".editorconfig", ".editorconfig-checker.json", ".ecrc")...

(EN_QUOTES)


[typographical] ~43-~43: Consider using a typographic opening quote here.
Context: ...uration file (default: ".editorconfig", ".editorconfig-checker.json", ".ecrc") ...

(EN_QUOTES)


[typographical] ~43-~43: Consider using a typographic close quote here.
Context: ...itorconfig", ".editorconfig-checker.json", ".ecrc") | |no | |...

(EN_QUOTES)


[typographical] ~43-~43: Consider using a typographic opening quote here.
Context: ...rconfig", ".editorconfig-checker.json", ".ecrc") | |no | |`--...

(EN_QUOTES)


[typographical] ~43-~43: Consider using a typographic close quote here.
Context: ...g", ".editorconfig-checker.json", ".ecrc") | |no | |`--disabl...

(EN_QUOTES)


[typographical] ~44-~44: Consider using typographic quotation marks here.
Context: ... |Disable end-of-line check (default "false") ...

(EN_QUOTES)


[typographical] ~45-~45: Consider using typographic quotation marks here.
Context: ... |Disable indent size check (default "false") ...

(EN_QUOTES)


[typographical] ~46-~46: Consider using typographic quotation marks here.
Context: ... |Disable indentation check (default "false") ...

(EN_QUOTES)


[typographical] ~47-~47: Consider using typographic quotation marks here.
Context: ... |Disable final newline check (default "false") ...

(EN_QUOTES)


[typographical] ~48-~48: Consider using typographic quotation marks here.
Context: ...|Disable max line length check (default "false") ...

(EN_QUOTES)


[typographical] ~49-~49: Consider using typographic quotation marks here.
Context: ...able trailing whitespace check (default "false") ...

(EN_QUOTES)


[typographical] ~50-~50: Consider using typographic quotation marks here.
Context: ...w which files would be checked (default "false") ...

(EN_QUOTES)


[typographical] ~52-~52: Consider using typographic quotation marks here.
Context: ...he output format: default, gcc (default "default") ...

(EN_QUOTES)


[typographical] ~53-~53: Consider using typographic quotation marks here.
Context: ... |help for editorconfig (default "false") ...

(EN_QUOTES)


[typographical] ~54-~54: Consider using typographic quotation marks here.
Context: ... |Ignore default excludes (default "false") ...

(EN_QUOTES)


[typographical] ~55-~55: Consider using typographic quotation marks here.
Context: ...eates an initial configuration (default "false") ...

(EN_QUOTES)


[typographical] ~56-~56: Consider using typographic quotation marks here.
Context: ... |Don't print colors (default "false") ...

(EN_QUOTES)


[typographical] ~57-~57: Consider using typographic quotation marks here.
Context: ... |Print the version number (default "false") ...

(EN_QUOTES)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 957011c and 29f957c.

📒 Files selected for processing (1)
  • website/docs/cli/commands/validate/validate-editorconfig.mdx (1 hunks)
🧰 Additional context used
🪛 LanguageTool
website/docs/cli/commands/validate/validate-editorconfig.mdx

[typographical] ~43-~43: Consider using a typographic opening quote here.
Context: ...ath to the configuration file (default: ".editorconfig", ".editorconfig-checker.j...

(EN_QUOTES)


[typographical] ~43-~43: Consider using a typographic close quote here.
Context: ...figuration file (default: ".editorconfig", ".editorconfig-checker.json", ".ecrc")...

(EN_QUOTES)


[typographical] ~43-~43: Consider using a typographic opening quote here.
Context: ...uration file (default: ".editorconfig", ".editorconfig-checker.json", ".ecrc") ...

(EN_QUOTES)


[typographical] ~43-~43: Consider using a typographic close quote here.
Context: ...itorconfig", ".editorconfig-checker.json", ".ecrc") | |no | |...

(EN_QUOTES)


[typographical] ~43-~43: Consider using a typographic opening quote here.
Context: ...rconfig", ".editorconfig-checker.json", ".ecrc") | |no | |`--...

(EN_QUOTES)


[typographical] ~43-~43: Consider using a typographic close quote here.
Context: ...g", ".editorconfig-checker.json", ".ecrc") | |no | |`--disabl...

(EN_QUOTES)


[typographical] ~44-~44: Consider using typographic quotation marks here.
Context: ... |Disable end-of-line check (default "false") ...

(EN_QUOTES)


[typographical] ~45-~45: Consider using typographic quotation marks here.
Context: ... |Disable indent size check (default "false") ...

(EN_QUOTES)


[typographical] ~46-~46: Consider using typographic quotation marks here.
Context: ... |Disable indentation check (default "false") ...

(EN_QUOTES)


[typographical] ~47-~47: Consider using typographic quotation marks here.
Context: ... |Disable final newline check (default "false") ...

(EN_QUOTES)


[typographical] ~48-~48: Consider using typographic quotation marks here.
Context: ...|Disable max line length check (default "false") ...

(EN_QUOTES)


[typographical] ~49-~49: Consider using typographic quotation marks here.
Context 8000 : ...able trailing whitespace check (default "false") ...

(EN_QUOTES)


[typographical] ~50-~50: Consider using typographic quotation marks here.
Context: ...w which files would be checked (default "false") ...

(EN_QUOTES)


[typographical] ~52-~52: Consider using typographic quotation marks here.
Context: ...he output format: default, gcc (default "default") ...

(EN_QUOTES)


[typographical] ~53-~53: Consider using typographic quotation marks here.
Context: ... |help for editorconfig (default "false") ...

(EN_QUOTES)


[typographical] ~54-~54: Consider using typographic quotation marks here.
Context: ... |Ignore default excludes (default "false") ...

(EN_QUOTES)


[typographical] ~55-~55: Consider using typographic quotation marks here.
Context: ...eates an initial configuration (default "false") ...

(EN_QUOTES)


[typographical] ~56-~56: Consider using typographic quotation marks here.
Context: ... |Don't print colors (default "false") ...

(EN_QUOTES)


[typographical] ~57-~57: Consider using typographic quotation marks here.
Context: ... |Print the version number (default "false") ...

(EN_QUOTES)

⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: Lint (golangci)
  • GitHub Check: Build (ubuntu-latest, linux)
  • GitHub Check: website-deploy-preview
  • GitHub Check: Analyze (go)
  • GitHub Check: Summary
🔇 Additional comments (1)
website/docs/cli/commands/validate/validate-editorconfig.mdx (1)

41-43: Update Flag Type for Config: The configuration flag is still labeled as --config string, but given the PR’s objective you should update it to reflect the new array-of-strings type (e.g., --config stringSlice). This change will ensure consistency between the documentation and the underlying implementation.
[suggest_nitpick, request_verification]

🧰 Tools
🪛 LanguageTool

[typographical] ~43-~43: Consider using a typographic opening quote here.
Context: ...ath to the configuration file (default: ".editorconfig", ".editorconfig-checker.j...

(EN_QUOTES)


[typographical] ~43-~43: Consider using a typographic close quote here.
Context: ...figuration file (default: ".editorconfig", ".editorconfig-checker.json", ".ecrc")...

(EN_QUOTES)


[typographical] ~43-~43: Consider using a typographic opening quote here.
Context: ...uration file (default: ".editorconfig", ".editorconfig-checker.json", ".ecrc") ...

(EN_QUOTES)


[typographical] ~43-~43: Consider using a typographic close quote here.
Context: ...itorconfig", ".editorconfig-checker.json", ".ecrc") | |no | |...

(EN_QUOTES)


[typographical] ~43-~43: Consider using a typographic opening quote here.
Context: ...rconfig", ".editorconfig-checker.json", ".ecrc") | |no | |`--...

(EN_QUOTES)


[typographical] ~43-~43: Consider using a typographic close quote here.
Context: ...g", ".editorconfig-checker.json", ".ecrc") | |no | |`--disabl...

(EN_QUOTES)

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 31, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 31, 2025
Copy link
Member
@aknysh aknysh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samtholiya please address the comment

@aknysh aknysh changed the title update config to be an array of string for editorconfig Support the --config flag as an array of strings for atmos validate editorconfig Apr 1, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 1, 2025
@aknysh aknysh merged commit 0d715f5 into main Apr 1, 2025
51 checks passed
@aknysh aknysh deleted the feature/dev-3111-update-the-config-flag-in-editorconfig branch April 1, 2025 03:03
Copy link
github-actions bot commented Apr 1, 2025

These changes were released in v1.169.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-release Do not create a new release (wait for additional code changes) size/s
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0