-
Notifications
You must be signed in to change notification settings - Fork 71
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 Py Scirpt Enforce CamelCase Naming Convention in Scala Code #384
base: master
Are you sure you want to change the base?
Conversation
In Scala, camelCase is the preferred naming convention for variables, functions, and methods. It enhances code clarity by visually grouping words together and avoiding potential confusion with underscores (which often have special meanings in Scala).
Thanks for your work and contribution. We need to address some issues before integrating this script into difftest.
Given the difficulties in designing a Scala formatter, I would suggest trying existing and mature format tools. I assume it's too diffcult for a single person to maintain a fully-functioning Scala formatter. Are there any existing format tools capable of handling camelCase conversion? |
Actually, I was trying to use Regarding the converted inline Verilog code, I converted it line by line without considering the code's functionality. I acknowledge that there might be more sophisticated approaches to achieve this, such as using abstract syntax trees (ASTs) to parse the Scala code, identify variables, and replace them. However, as you mentioned, maintaining such a solution could be challenging for a single person. Based on my research, Scala lacks a dedicated tool for this conversion due to its relatively smaller user base compared to languages like Java. Although there are discussions about similar issues for Java, even their best solutions involve using regular expressions with subsequent manual checks.😥 Therefore, my final suggestions are to either gradually change the code style or create a custom tool for this task, although the latter could be quite complex. |
I see. So there are no existing tools for converting variables to camelCase. I agree with your suggestions on gradually changing the code style and creating a custom tool for camelCase formatting. Since this PR has some issues to be address, I would prefer to convert this PR to draft (or an issue) and see whether in the future we can find an appropriate way to do the formatting. |
Still, thanks very much for your contribution and your research. It's much helpful for the project |
I'm happy to contribute to the open-source community and plan to submit an issue to the |
Thanks very much for your efforts! |
Pull Request: Add Py Scirpt Enforce CamelCase Naming Convention in Scala Code
Description
This pull request introduces the
check_camel_case.py
script to the project. This script helps maintain consistent code style by automatically identifying and optionally fixing variables and functions named with underscores (snake_case) in the Scala files. Consistent use of camelCase improves readability and adheres to common Scala conventions.Why CamelCase?
In Scala, camelCase is the preferred naming convention for variables, functions, and methods. It enhances code clarity by visually grouping words together and avoiding potential confusion with underscores (which often have special meanings in Scala).
Key Improvements
.scala
files within a specified directory to find instances of snake_case naming.--fix
flag, the script automatically replaces snake_case names with their camelCase equivalents, saving manual effort.Usage
check_camel_case.py
is located in the root directory of the project.<directory>
with the path to the directory containing your Scala code, e.g.,src
)Example Output
Additional Notes