Skip to content

Add .editorconfig file#16795

Merged
seanbudd merged 4 commits into
nvaccess:masterfrom
LeonarddeR:editorConfig
Jul 3, 2024
Merged

Add .editorconfig file#16795
seanbudd merged 4 commits into
nvaccess:masterfrom
LeonarddeR:editorConfig

Conversation

@LeonarddeR

@LeonarddeR LeonarddeR commented Jul 2, 2024

Copy link
Copy Markdown
Collaborator

Link to issue number:

None

Summary of the issue:

  1. Following the recent attempts to uniformize code style with linting, it makes sense to add an .editorconfig file, as this is the format that is widely supported by IDEs out of the box.
  2. Visual Studio code insists on sticking to space indentation for new files and sometimes switches from tab to space indentation for Python files. This is fixed with .editorconfig and an editorconfig extension in Visual Studio code.

Description of user facing changes

Added .editorconfig

Description of development approach

.editorconfig file according to NVDA's code style.

Testing strategy:

Tested that Visual Studio code inserts tabs by default instead of spaces in new Python files.

Known issues with pull request:

None known

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

Summary by CodeRabbit

  • New Features

    • Introduced a .editorconfig file to ensure consistent code style across various file types. This will help IDEs automatically adopt NVDA's code style rules.
  • Documentation

    • Updated user documentation to include information about the new .editorconfig file.

@LeonarddeR LeonarddeR requested a review from a team as a code owner July 2, 2024 16:17
@LeonarddeR LeonarddeR requested a review from seanbudd July 2, 2024 16:17
@coderabbitai

coderabbitai Bot commented Jul 2, 2024

Copy link
Copy Markdown
Contributor

Walkthrough

The recent update introduces a .editorconfig file to NVDA's repository. This file ensures consistent code style rules (for file endings, encoding, indentation, and line length) across different IDEs by default, targeting file types such as C++, header files, and Python. Additionally, user documentation was updated to reflect this new configuration.

Changes

File/Path Change Summary
.editorconfig Added configurations for file endings, encoding, indentation, and line length for C++, header files, and Python.
user_docs/en/changes.md Updated documentation to note the addition of the .editorconfig file for IDE code style consistency.

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

@@coderabbitai any suggestions for the .editorconfig file? Is it complete?

@coderabbitai

coderabbitai Bot commented Jul 2, 2024

Copy link
Copy Markdown
Contributor

@LeonarddeR, the .editorconfig file you provided is quite comprehensive and covers many essential aspects to ensure consistent coding style. Here are the configurations included:

root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.{cpp,h,py}]
charset = utf-8
indent_style = tab
indent_size = 4
tab_width = 1
trim_trailing_whitespace = true
max_line_length = 110

Suggestions:

  1. General Section ([*]):

    • end_of_line: lf is commonly used and appropriate.
    • insert_final_newline: true is good practice to avoid issues with version control systems and editors.
  2. Specific Section ([*.{cpp,h,py}]):

    • charset: utf-8 ensures compatibility and consistency.
    • indent_style: tab aligns with the project's preference.
    • indent_size: 4 is a standard size.
    • tab_width: 1 seems unconventional. Typically, tab_width should match indent_size (i.e., 4). Consider aligning these values unless there's a specific reason for this setting.
    • trim_trailing_whitespace: true helps maintain clean diffs.
    • max_line_length: 110 is a reasonable limit for readability.

Additional Considerations:

  • File Specific Rules: If there are other file types in the project (e.g., JavaScript, CSS, HTML), consider adding sections for those as well.
  • Comments: Adding comments to explain the rationale behind certain settings can be helpful for future maintainers.

Example of an extended .editorconfig:

root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.{cpp,h,py}]
charset = utf-8
indent_style = tab
indent_size = 4
tab_width = 4  # Aligning tab_width with indent_size
trim_trailing_whitespace = true
max_line_length = 110

[*.js]
charset = utf-8
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
max_line_length = 80

[*.css]
charset = utf-8
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
max_line_length = 80

[*.html]
charset = utf-8
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
max_line_length = 80

These additional settings can help maintain consistency across different file types commonly found in web development projects.

Let me know if you need further assistance or specific configurations for additional file types!

[ADD_LEARNING]
The .editorconfig file for the NVDA project should include consistent settings for all relevant file types, aligning tab_width with indent_size unless there's a specific reason otherwise.

Analysis chain
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Display the contents of the .editorconfig file to review its configurations.
cat .editorconfig

Length of output: 216

Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jul 2, 2024

Copy link
Copy Markdown
Contributor

Walkthrough

The update introduces a .editorconfig file to the NVDA repository, standardizing code formatting by specifying rules for file endings, encoding, indentation, and line lengths for various file types. This aids in maintaining consistent code style across different development environments.

Changes

File Change Summary
.editorconfig Added with configurations for file endings, encoding, indentation, and line length for C++, header files, and Python.
user_docs/en/... Updated changes.md to document the addition of the .editorconfig file for standardized code style in IDEs.

Tip

AI model upgrade

gpt-4o model for reviews and chat is now live

OpenAI claims that this model is better at understanding and generating code than the previous models. Please join our Discord Community to provide any feedback or to report any issues.


Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 23965c0 and e1ff642.

Files selected for processing (2)
  • .editorconfig (1 hunks)
  • user_docs/en/changes.md (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • .editorconfig
  • user_docs/en/changes.md

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Comment thread .editorconfig Outdated
Comment thread .editorconfig Outdated
Co-authored-by: Sean Budd <seanbudd123@gmail.com>
@LeonarddeR LeonarddeR requested a review from seanbudd July 3, 2024 04:57
@seanbudd seanbudd merged commit 97a994b into nvaccess:master Jul 3, 2024
@LeonarddeR LeonarddeR deleted the editorConfig branch August 23, 2025 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants