Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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! 🌱
70 changes: 66 additions & 4 deletions getstarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Before you start, make sure you have:

## Installation

### 0. Install RUST and Cargo

Please check installation instructions for [Rust](https://www.rust-lang.org/tools/install) if you haven't installed Rust yet.

### 1. Install Required Tools

```bash
Expand All @@ -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 (Windows PowerShell/Command Prompt) :
cd .\creedengo-rust-test
cargo dylint --path ../creedengo-rust
```


### Method 2: Workspace Metadata Configuration

Add the following to your project's `Cargo.toml`:
Expand All @@ -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:
Comment on lines +67 to +77
Copy link

Copilot AI Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] These in-doc TODO comments should be moved to GitHub issues or removed once addressed to keep documentation clean.

Suggested change
#### 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:
- In `creedengo-rust-test/Cargo.toml`, add the following lines:
```toml
[workspace.metadata.dylint]
libraries = [
{ path = "../creedengo-rust" }
]
  • Then run the command:

Copilot uses AI. Check for mistakes.

```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`:
Expand All @@ -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
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -188,5 +239,16 @@ rustup override set nightly
## Resources

- [Dylint GitHub Repository](https://github.com/trailofbits/dylint)
- [ecoCode Project](https://github.com/green-code-initiative/ecoCode)
- [Green Code Initiative](https://www.green-code-initiative.org/)
- [Creedengo Project](https://github.com/green-code-initiative/creedengo-rules-specifications)
- [Green Code Initiative](https://www.green-code-initiative.org/)

### TODO DDC - refactoring this repository
- 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
- 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 ?
13 changes: 6 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
@@ -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
------------------
Expand All @@ -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.