From 66e2d4192c38d7353ca7216f4949e06ab53ea49c Mon Sep 17 00:00:00 2001 From: David DE CARVALHO Date: Thu, 3 Jul 2025 22:42:25 +0200 Subject: [PATCH 1/3] replace ecocode to creedengo in documentation --- CONTRIBUTING.md | 8 ++++---- getstarted.md | 2 +- readme.md | 13 ++++++------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7dafbee..6048c02 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ Thank you for your interest in contributing to creedengo-rust! This document provides guidelines for adding new dylint rules and contributing to the project. -Please also read the common [CONTRIBUTING.md](https://github.com/green-code-initiative/ecoCode-common/blob/main/doc/CONTRIBUTING.md) in `ecoCode-common` repository for general ecoCode contribution guidelines. +Please also read the common [CONTRIBUTING.md](https://github.com/green-code-initiative/creedengo-common/blob/main/doc/CONTRIBUTING.md) in `creedengo-common` repository for general Creedengo contribution guidelines. ## Table of Contents @@ -259,8 +259,8 @@ Add your rule to the rules table in `readme.md`: - [HIR Documentation](https://rustc-dev-guide.rust-lang.org/hir.html) - [Writing Clippy Lints](https://github.com/rust-lang/rust-clippy/blob/master/book/src/development/adding_lints.md) -### ecoCode Resources -- [ecoCode Rules Specifications](https://github.com/green-code-initiative/creedengo-rules-specifications) +### Creedengo Resources +- [Creedengo Rules Specifications](https://github.com/green-code-initiative/creedengo-rules-specifications) - [Green Code Initiative](https://www.green-code-initiative.org/) ## Getting Help @@ -270,6 +270,6 @@ If you need help: 1. Check the [dylint documentation](https://github.com/trailofbits/dylint) 2. Look at existing rules in this repository for examples 3. Open an issue in this repository for project-specific questions -4. Join the ecoCode community discussions +4. Join the Creedengo community discussions Thank you for contributing to a more sustainable software ecosystem! 🌱 \ No newline at end of file diff --git a/getstarted.md b/getstarted.md index a4756c1..2ef65d6 100644 --- a/getstarted.md +++ b/getstarted.md @@ -188,5 +188,5 @@ rustup override set nightly ## Resources - [Dylint GitHub Repository](https://github.com/trailofbits/dylint) -- [ecoCode Project](https://github.com/green-code-initiative/ecoCode) +- [Creedengo Project](https://github.com/green-code-initiative/creedengo-rules-specifications) - [Green Code Initiative](https://www.green-code-initiative.org/) \ No newline at end of file diff --git a/readme.md b/readme.md index b4a4d2e..f0ccc1c 100644 --- a/readme.md +++ b/readme.md @@ -1,16 +1,15 @@ -[![EcoCode on NuGet](https://img.shields.io/nuget/v/EcoCode.svg)](https://www.nuget.org/packages/EcoCode/) [![EcoCode on NuGet](https://img.shields.io/nuget/dt/EcoCode)](https://www.nuget.org/packages/EcoCode/) - creedengo-rust +================ -_ecoCode_ is a collective project aiming to reduce environmental footprint of software at the code level. The goal of the project is to provide a list of static code analyzers to highlight code structures that may have a negative ecological impact: energy and resources over-consumption, "fatware", shortening terminals' lifespan, etc. +_Creedengo_ is a collective project aiming to reduce environmental footprint of software at the code level. The goal of the project is to provide a list of static code analyzers to highlight code structures that may have a negative ecological impact: energy and resources over-consumption, "fatware", shortening terminals' lifespan, etc. -_ecoCode_ is based on evolving catalogs of [good practices](https://github.com/green-code-initiative/ecoCode/blob/main/docs/rules), for various technologies. +_Creedengo_ is based on evolving catalogs of [good practices](https://github.com/green-code-initiative/creedengo-rules-specifications/blob/main/docs/rules), for various technologies. This set of [Clippy](https://github.com/rust-lang/rust-clippy) linters implements these catalogs as rules for scanning your Rust projects using [DyLint](https://github.com/trailofbits/dylint). > ⚠️ 🚧 This is still a very early stage project 🚧. Any feedback or contribution will be highly appreciated. Please refer to the contribution section. -[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](https://github.com/green-code-initiative/ecoCode-common/blob/main/doc/CODE_OF_CONDUCT.md) +[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](https://github.com/green-code-initiative/creedengo-common/blob/main/doc/CODE_OF_CONDUCT.md) 🚀 Getting Started ------------------ @@ -35,9 +34,9 @@ This project requires: 🤝 Contribution --------------- -See [contribution](https://github.com/green-code-initiative/ecoCode#-contribution) on the central ecoCode repository. +See [contribution](https://github.com/green-code-initiative/creedengo-rules-specifications#-contribution) on the central Creedengo repository. 🤓 Main contributors -------------------- -See [main contributors](https://github.com/green-code-initiative/ecoCode#-main-contributors) on the central ecoCode repository. +See [main contributors](https://github.com/green-code-initiative/creedengo-rules-specifications#-main-contributors) on the central Creedengo repository. From d79c294f819fb733c9d6a284b95dcf8f3da667d3 Mon Sep 17 00:00:00 2001 From: David DE CARVALHO Date: Fri, 4 Jul 2025 00:23:06 +0200 Subject: [PATCH 2/3] add my test comments - TODO DDC sections --- getstarted.md | 68 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 65 insertions(+), 3 deletions(-) diff --git a/getstarted.md b/getstarted.md index 2ef65d6..dd302a1 100644 --- a/getstarted.md +++ b/getstarted.md @@ -11,6 +11,10 @@ Before you start, make sure you have: ## Installation +### 0. Install RUST and Cargo + +Please check iunstallation instructions for [Rust](https://www.rust-lang.org/tools/install) if you haven't installed Rust yet. + ### 1. Install Required Tools ```bash @@ -35,9 +39,14 @@ rustup default nightly Navigate to your Rust project directory and run: ```bash -cargo dylint --path path/to/creedengo-rust/creedengo-rust +cargo dylint --path path/to/creedengo-rust-project + +# example : +cd .\creedengo-rust-test +cargo dylint --path ../creedengo-rust ``` + ### Method 2: Workspace Metadata Configuration Add the following to your project's `Cargo.toml`: @@ -55,6 +64,25 @@ Then run: cargo dylint --all ``` +#### TODO DDC - check with an example NOT OK + +TODO DDC : check this option, because not ok for me +- in creedengo-rust-test/Cargo.toml, adding the following lines: +```toml +[workspace.metadata.dylint] +libraries = [ + { path = "../creedengo-rust" } +] +``` +- next run the command: +```bash +cargo dylint --all +``` +but error: +``` +Warning: No libraries were found. +``` + ### Method 3: Git Repository Configuration For a more permanent setup, add this to your `Cargo.toml`: @@ -66,9 +94,13 @@ libraries = [ ] ``` +#### TODO DDC - check with an example +- where to add these lines +- how to check if it works ? + ## VS Code Integration -To see dylint warnings directly in VS Code, add the following to your `.vscode/settings.json`: +After installing rust-analyzer extension in VSCode, to see dylint warnings directly in VS Code, add the following to your `.vscode/settings.json`: ```json { @@ -99,6 +131,11 @@ For workspace metadata configuration, use: } ``` +#### TODO DDC - check with an example +- where to add these two blocks ? +- error when in creedengo-rust base repository because several Cargo.tom files found + - maybe launch VS Code only inside a subdirectory like creedengo-rust-test ? and add .vscode/settings.json in this subdirectory ? + ## Available Rules ### GCI2 - Avoid Multiple If-Else Statements @@ -137,6 +174,10 @@ fn get_status_message(code: u16) -> &'static str { } ``` +#### TODO DDC - check the relevance of this rule for RUST +- how did you test that this rule is ok for RUST ? +- maybe this rule is not relevant for RUST ? I think we have to measure the relevance for RUST with some frameworks / tools like Code Carbon for python language + ## Building the Project To build the creedengo-rust library: @@ -146,6 +187,10 @@ cd creedengo-rust cargo build --release ``` +### TODO DDC - question +- why do we need to build the project ? is it necessary for dylint ? +- what is the production of this command ? where is the output ? + ## Testing To run the tests: @@ -155,6 +200,12 @@ cd creedengo-rust cargo test ``` +### TODO DDC - question +- how does test command detect the tests in "ui" directory ? +- "ui" directory is the standard directory for dylint tests ? +- I don't understand how the tests are run, because I don't see any test function in the "ui" directory +- I see a test bloc in src/lib.rs file : is it the standard way to test dylint rules ? It seems strange to me to add test code in the same file as the rules implementation. + ## Troubleshooting ### Issue: `cargo dylint` command not found @@ -189,4 +240,15 @@ rustup override set nightly - [Dylint GitHub Repository](https://github.com/trailofbits/dylint) - [Creedengo Project](https://github.com/green-code-initiative/creedengo-rules-specifications) -- [Green Code Initiative](https://www.green-code-initiative.org/) \ No newline at end of file +- [Green Code Initiative](https://www.green-code-initiative.org/) + +### TODO DDC - refactoring this repository +- the repository inside green-code-inititiative organization in github is called "creedengo-rust" +- but there are 3 current sub-directories: + - creedengo-rust => this one contains the rule implementation, and must be renamed with another name + - creedengo-rust-test => this one is a test project to test the rules in real environment + - creedengo-rust-sonar => this one is for SonarQube integration + - do you check it on a sonarqube server ? +- do we have to commit Cargo.lock files ? for me, no, because there are autogenerated files, and we don't need to commit autogenerated files. are you ok to add these files in .gitignore ? +- maybe add a section to explain sonarqube integration adn the content of creedengo-rust-sonar directory ? + - the "restart_sonar.ps1" seems to be a script file for windows, but I'm on MacOS :p ... maybe can we write a bash script for unix / MacOS users also ? \ No newline at end of file From e0ef4196b210d695581303305e36aad9a6f910c1 Mon Sep 17 00:00:00 2001 From: David DE CARVALHO Date: Fri, 4 Jul 2025 09:39:21 +0200 Subject: [PATCH 3/3] typo --- getstarted.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/getstarted.md b/getstarted.md index dd302a1..3733b80 100644 --- a/getstarted.md +++ b/getstarted.md @@ -13,7 +13,7 @@ Before you start, make sure you have: ### 0. Install RUST and Cargo -Please check iunstallation instructions for [Rust](https://www.rust-lang.org/tools/install) if you haven't installed Rust yet. +Please check installation instructions for [Rust](https://www.rust-lang.org/tools/install) if you haven't installed Rust yet. ### 1. Install Required Tools @@ -41,7 +41,7 @@ Navigate to your Rust project directory and run: ```bash cargo dylint --path path/to/creedengo-rust-project -# example : +# example (Windows PowerShell/Command Prompt) : cd .\creedengo-rust-test cargo dylint --path ../creedengo-rust ``` @@ -243,7 +243,7 @@ rustup override set nightly - [Green Code Initiative](https://www.green-code-initiative.org/) ### TODO DDC - refactoring this repository -- the repository inside green-code-inititiative organization in github is called "creedengo-rust" +- the repository inside green-code-initiative organization in github is called "creedengo-rust" - but there are 3 current sub-directories: - creedengo-rust => this one contains the rule implementation, and must be renamed with another name - creedengo-rust-test => this one is a test project to test the rules in real environment