Skip to content
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

Update editorconfig to version 3.1.2 #955

Merged

Conversation

samtholiya
Copy link
Collaborator

@samtholiya samtholiya commented Jan 19, 2025

what

  • Update editorconfig library to latest v3.1.2

why

  • Supports many new features mentioned in release notes here

Why snapshots changed

The new update consolidates the errors
Old error display strategy accoding to v3.0.3:
image
In the above image the lines were shown as two different errors

New error display strategy according to v3.1.2
image
Now the error line is single mentioning the error in both the lines

references

Summary by CodeRabbit

  • New Features

    • Enhanced EditorConfig validation command with support for multiple configuration file names.
    • Detailed usage guide added for the atmos validate editorconfig command, including flags and options.
    • New test cases for help and usage commands related to EditorConfig validation.
  • Bug Fixes

    • Streamlined error reporting for configuration validation.
    • Updated error message formatting for left-padding space issues.
    • Added error messages for unknown commands and invalid subcommands.
  • Chores

    • Updated project dependencies to latest versions.
    • Refined CLI command output and error handling.

@samtholiya samtholiya requested a review from a team as a code owner January 19, 2025 11:28
@mergify mergify bot added the triage Needs triage label Jan 19, 2025
Copy link
Contributor

coderabbitai bot commented Jan 19, 2025

📝 Walkthrough

Walkthrough

The pull request introduces enhancements to the EditorConfig validation command in the cmd/validate_editorconfig.go file. Key changes include expanding support for multiple configuration file names, improving configuration file path handling, and refining output format validation. These modifications allow for more flexible configuration loading and streamline error reporting for the EditorConfig validation process.

Changes

File Change Summary
cmd/validate_editorconfig.go - Added defaultConfigFileNames slice with multiple config file names
- Updated initializeConfig to handle multiple config paths
- Modified format validation using outputformat package
- Simplified error handling in runMainLogic
go.mod Updated dependency versions:
- editorconfig-checker/v3 to v3.1.2
- gabriel-vasile/mimetype to v1.4.8
- goccy/go-yaml to v1.15.13
tests/snapshots/* Updated test snapshots to reflect new error reporting format
tests/test-cases/validate-editorconfig.yaml Modified test case expectations for error output

Assessment against linked issues

Objective Addressed Explanation
Update editorconfig library to 3.1.2 [DEV-2952]

Possibly related PRs

  • Add editorconfig validation #896: The main PR introduces validation for .editorconfig files, which is directly related to the changes in the cmd/validate_editorconfig.go file that enhance the CLI's ability to validate configurations against EditorConfig rules.
  • update eol settings #928: This PR updates the .editorconfig settings to enforce LF line endings, which is relevant to the main PR's focus on EditorConfig validation, ensuring consistent formatting rules are applied.

Suggested labels

minor

Suggested reviewers

  • aknysh
  • 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 8874ad5 and fdc4035.

📒 Files selected for processing (6)
  • cmd/validate_editorconfig.go (7 hunks)
  • internal/tui/templates/base_template.go (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_--help.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_validate_editorconfig_help.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_check_atmos_--help_in_empty-dir.stdout.golden (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • tests/snapshots/TestCLICommands_atmos_--help.stdout.golden
  • tests/snapshots/TestCLICommands_check_atmos_--help_in_empty-dir.stdout.golden
🚧 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 (2)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: Summary
🔇 Additional comments (5)
internal/tui/templates/base_template.go (1)

99-99: LGTM! Clean and precise help text.

The removal of the redundant "atmos" prefix from the command path example makes the help text cleaner, as the command path already includes the binary name.

cmd/validate_editorconfig.go (4)

22-29: Strong improvement in configuration handling, warrior! 🛡️

The addition of multiple configuration file support (defaultConfigFileNames) enhances flexibility by supporting various common EditorConfig file names (.editorconfig, .editorconfig-checker.json, .ecrc).


94-104: Battle-tested format validation needs reinforcement! ⚔️

The format validation logic is duplicated. Consider extracting it into a separate function as suggested in the previous review.


159-163: Clean error handling, warrior! 🗡️

The simplified error handling with debug logging and standard exit code (1) follows good practices and Unix conventions.


189-189: Well-structured flag handling! 🏹

The separation of format flag handling using a dedicated variable follows Cobra best practices.

Finishing Touches

  • 📝 Generate Docstrings (Beta)

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?

❤️ Share
🪧 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. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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: 1

🧹 Nitpick comments (1)
cmd/validate_editorconfig.go (1)

156-160: Clean error handling, but let's add some battle logs! 🗡️

The simplified error handling is good, but consider adding debug logging before exit.

 er.PrintErrors(errors, config)
 u.LogDebug(atmosConfig, fmt.Sprintf("%d files checked", len(filePaths)))
 errorCount := er.GetErrorCount(errors)
 if errorCount != 0 {
+    u.LogDebug(atmosConfig, fmt.Sprintf("Validation failed with %d errors", errorCount))
     os.Exit(1)
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1a88f87 and cc382f6.

📒 Files selected for processing (1)
  • cmd/validate_editorconfig.go (7 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (22)
  • GitHub Check: [mock-macos] tests/fixtures/scenarios/complete
  • GitHub Check: [mock-macos] examples/demo-vendoring
  • GitHub Check: [mock-macos] examples/demo-context
  • GitHub Check: [mock-macos] examples/demo-component-versions
  • GitHub Check: [mock-macos] examples/demo-atlantis
  • GitHub Check: [mock-windows] tests/fixtures/scenarios/complete
  • GitHub Check: [mock-windows] examples/demo-vendoring
  • GitHub Check: [mock-windows] examples/demo-context
  • GitHub Check: [mock-windows] examples/demo-component-versions
  • GitHub Check: [mock-windows] examples/demo-atlantis
  • GitHub Check: [mock-linux] tests/fixtures/scenarios/complete
  • GitHub Check: [mock-linux] examples/demo-vendoring
  • GitHub Check: [mock-linux] examples/demo-context
  • GitHub Check: [mock-linux] examples/demo-component-versions
  • GitHub Check: Acceptance Tests (macos-latest, macos)
  • GitHub Check: [mock-linux] examples/demo-atlantis
  • GitHub Check: Acceptance Tests (windows-latest, windows)
  • GitHub Check: Acceptance Tests (ubuntu-latest, linux)
  • GitHub Check: [localstack] demo-localstack
  • GitHub Check: [k3s] demo-helmfile
  • GitHub Check: Docker Lint
  • GitHub Check: Summary
🔇 Additional comments (3)
cmd/validate_editorconfig.go (3)

22-29: Well structured variable declarations, warrior! 💪

The introduction of defaultConfigFileNames slice with multiple config file options (.editorconfig, .editorconfig-checker.json, .ecrc) provides excellent flexibility for users.


15-17: Verify editorconfig-checker version alignment! 🎯

The imports are correctly using v3, but let's verify the exact version in go.mod.

✅ Verification successful

Version alignment confirmed! 💪

The imports correctly use v3 path and align perfectly with go.mod's v3.1.2 specification. Keep marching forward!

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify editorconfig-checker version
grep -r "github.com/editorconfig-checker/editorconfig-checker/v3" go.mod

Length of output: 136


49-56: Strong configuration initialization approach! 🛡️

The new configuration path handling is more robust, supporting multiple config file locations. However, let's verify the behavior when multiple config files exist.

✅ Verification successful

Configuration handling is battle-tested! 💪

The implementation correctly handles multiple config files with a clear priority order. When multiple config files exist, they are processed hierarchically:

  • System directory configs are loaded first
  • Home directory configs are merged next
  • Current directory configs take precedence
  • Environment variables and command-line arguments get highest priority
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the code handles multiple config files correctly
ast-grep --pattern 'NewConfig($paths)' | rg -A 5 'NewConfig'

Length of output: 60


Script:

#!/bin/bash
# Find config-related files
fd "config.*\.go$"

# Search for NewConfig function implementation
rg -l "func NewConfig"

# Look for multiple config handling logic
rg -A 5 "type Config struct" 

Length of output: 827


Script:

#!/bin/bash
# Examine the config package implementation
cat pkg/config/config.go

# Look for specific config loading patterns
rg -A 10 "func NewConfig" pkg/config/config.go

# Check for any config merging or priority logic
rg -A 5 "load.*config" pkg/config/config.go

Length of output: 13658

@aknysh aknysh added no-release Do not create a new release (wait for additional code changes) and removed triage Needs triage labels Jan 19, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 19, 2025
aknysh
aknysh previously approved these changes Jan 19, 2025
@samtholiya samtholiya dismissed stale reviews from aknysh and coderabbitai[bot] via 8874ad5 January 19, 2025 15:19
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: 1

🧹 Nitpick comments (3)
tests/test-cases/help-and-usage.yaml (3)

434-446: Add stdout/stderr expectations for consistency.

The test case should include stdout/stderr expectations like other help command tests in this file. This ensures we validate both the exit code and the expected output.

    expect:
+     stdout:
+       - "Usage:"
+       - "Flags:"
+     stderr:
+       - "^$"
      exit_code: 0

460-472: Add stderr expectation for error message.

The test case should verify the error message for the non-existent subcommand, following the pattern of other similar tests in this file.

    expect:
+     stderr:
+       - 'Error: Unknown command \"non-existant\" for \"atmos validate editorconfig\"'
      exit_code: 1

473-473: Remove extra blank lines at the end of file.

The file has too many blank lines at the end. Keep only one blank line.

🧰 Tools
🪛 yamllint (1.35.1)

[warning] 473-473: too many blank lines

(1 > 0) (empty-lines)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cc382f6 and 8874ad5.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (6)
  • cmd/validate_editorconfig.go (7 hunks)
  • tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_validate_editorconfig_help.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_validate_editorconfig_non-existant.stderr.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_validate_editorconfig_non-existant.stdout.golden (1 hunks)
  • tests/test-cases/help-and-usage.yaml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • tests/snapshots/TestCLICommands_atmos_validate_editorconfig_non-existant.stdout.golden
🧰 Additional context used
🪛 yamllint (1.35.1)
tests/test-cases/help-and-usage.yaml

[warning] 473-473: too many blank lines

(1 > 0) (empty-lines)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: Summary
🔇 Additional comments (7)
tests/snapshots/TestCLICommands_atmos_validate_editorconfig_non-existant.stderr.golden (1)

1-2: Error message looks good!

The error message is clear, concise, and follows standard CLI error message format.

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

1-73: Help text structure looks good!

The help text is well-organized, comprehensive, and follows standard CLI help format.

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

1-78: Skipping review of duplicate help text.

This file contains identical content to tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden.

cmd/validate_editorconfig.go (3)

22-29: Good enhancement to configuration file support!

The addition of multiple default config file names (defaultConfigFileNames) improves flexibility by supporting various common EditorConfig file names.


94-104: Format validation needs refactoring.

The format validation logic is duplicated and contains an incorrect error message in the second validation block.

This is a duplicate of a previous review comment. The suggested refactoring to extract the validation logic and fix the error message is still valid.


Line range hint 139-164: Streamlined error handling looks good!

The error handling has been simplified:

  • Debug logging of config and file paths
  • Clear error count tracking
  • Simple exit with status code 1 on errors
tests/test-cases/help-and-usage.yaml (1)

447-459: Similar stdout/stderr expectations needed here.

Same feedback as the previous test case applies here.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 19, 2025
@aknysh aknysh merged commit 07c9e71 into main Jan 19, 2025
44 checks passed
@aknysh aknysh deleted the feature/dev-2952-update-editorconfig-library-version-to-312 branch January 19, 2025 18:32
Copy link

These changes were released in v1.152.1.

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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants