JiaLiangC opened a new pull request, #3908: URL: https://github.com/apache/ambari/pull/3908
## What changes were proposed in this pull request? The entire Ambari project has accumulated a large amount of Python code, which is the result of the collective efforts of multiple contributors to make Ambari better. | Language | Files | Lines | Code | Comments | Blanks | |-------------|-------|--------|--------|----------|--------| | Java | 3330 | 690679 | 427116 | 156389 | 107174 | | JavaScript | 2125 | 512742 | 374238 | 87081 | 51423 | | Plain Text | 68 | 500082 | 0 | 497409 | 2673 | | JSON | 758 | 479988 | 479689 | 0 | 299 | | Python | 1096 | 218057 | 175499 | 9547 | 33011 | | XML | 1135 | 156581 | 130300 | 20189 | 6092 | During this process, a problem has emerged: everyone has different coding styles, which leads to inconsistencies in the submitted code. This can result in various inconveniences, such as increased understanding costs of the underlying principles and greater difficulty in identifying the root causes of issues. As the codebase grows, these problems become increasingly apparent. Therefore, we are introducing [ruff](https://github.com/astral-sh/ruff), along with some additional processes, to format the code and alleviate these issues. What is Ruff? An extremely fast Python linter and code formatter, written in Rust. Its speed is one of its advantages. More information can be found here: [ruff](https://github.com/astral-sh/ruff). (Please fill in changes proposed in this fix) Ruff rules are derived from the Apache Superset project's rule file. Ruff integration plan: 1. Project integration with Ruff, formatting all Python files, ensuring all tests pass, and the cluster runs normally. Completed. 2. Integration of Ruff detection into Jenkins. Completed. Notice: This PR's Ruff rules ignore some rule checks because these rules involve significant changes that will be addressed in subsequent PRs. The current PR ensures that all Python indentation and basic formatting conform to standards. --- ### Ruff Usage Instructions in Ambari Code Submission **Install Ruff:** ```bash pip install ruff ``` **Format Code with Ruff:** ```bash ruff format . ``` **Check Code Format Manually:** ```bash ruff check . ``` **Check Code Format with Maven:** ```bash mvn exec:exec@ruff-check -Pruff-check ``` **Fix Code Format with Maven:** ```bash mvn exec:exec@ruff-format -Pruff-format ``` ## How was this patch tested? manual test CI/CD After formatting thousands of files with Ruff, I deployed a simple cluster to verify that Ambari runs smoothly.  (Please explain how this patch was tested. Ex: unit tests, manual tests) (If this patch involves UI changes, please attach a screen-shot; otherwise, remove this) Please review [Ambari Contributing Guide](https://cwiki.apache.org/confluence/display/AMBARI/How+to+Contribute) before opening a pull request. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
