Skip to content

Commit

Permalink
Merge branch 'main' into feature/optimize-rules-specifications-artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
dedece35 authored Sep 22, 2023
2 parents 34ee036 + 5783040 commit 788fd55
Show file tree
Hide file tree
Showing 179 changed files with 2,429 additions and 4,413 deletions.
42 changes: 0 additions & 42 deletions .github/workflows/manual_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,45 +89,3 @@ jobs:
asset_path: lib/ecocode-java-plugin-${{ needs.build.outputs.last_tag }}.jar
asset_name: ecocode-java-plugin-${{ needs.build.outputs.last_tag }}.jar
asset_content_type: application/zip
upload-php:
name: Upload PHP Plugin
runs-on: ubuntu-latest
needs: build
steps:
- name: Import plugin JAR files
id: import_jar_files
uses: actions/download-artifact@v3
with:
name: ecocode-plugins
path: lib
- name: Upload Release Asset - PHP Plugin
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{needs.build.outputs.upload_url}}
asset_path: lib/ecocode-php-plugin-${{ needs.build.outputs.last_tag }}.jar
asset_name: ecocode-php-plugin-${{ needs.build.outputs.last_tag }}.jar
asset_content_type: application/zip
upload-python:
name: Upload Python Plugin
runs-on: ubuntu-latest
needs: build
steps:
- name: Import plugin JAR files
id: import_jar_files
uses: actions/download-artifact@v3
with:
name: ecocode-plugins
path: lib
- name: Upload Release Asset - Python Plugin
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{needs.build.outputs.upload_url}}
asset_path: lib/ecocode-python-plugin-${{ needs.build.outputs.last_tag }}.jar
asset_name: ecocode-python-plugin-${{ needs.build.outputs.last_tag }}.jar
asset_content_type: application/zip
56 changes: 56 additions & 0 deletions .github/workflows/publish_to_maven_central.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# This workflow will build a Java project with Maven and publish artifact to Maven Central (https://search.maven.org)
#
# After deploy to https://s01.oss.sonatype.org finished, manual steps is required :
# - Go to: https://s01.oss.sonatype.org/#stagingRepositories
# - Check upload and if all is right, "Close" corresponding Staging Repository
# - "Release" corresponding Staging Repository
# - Wait some hours and then check availability of release on Maven central: https://search.maven.org/search?q=g:io.ecocode
#
# Additional information:
# - https://docs.github.com/en/actions/publishing-packages/publishing-java-packages-with-maven#publishing-packages-to-the-maven-central-repository
# - https://blogs.itemis.com/en/github-actions-releasing-artifacts-into-maven-central

name: Publish package to the Maven Central Repository

on:
workflow_dispatch:

jobs:
publish:
name: Deploy to Maven central
runs-on: ubuntu-latest

steps:
# Checks out a copy of project's repository.
- name: Checkout
uses: actions/checkout@v3

# Sets up the Java JDK, and also configures the Maven `settings.xml` file to add authentication for the
# `ossrh` repository using the `OSSRH_USERNAME` and `OSSRH_TOKEN` environment variables.
- name: Set up Maven Central Repository
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
server-id: 'ossrh' # must match the serverId configured for the nexus-staging-maven-plugin in `pom.xml`
server-username: OSSRH_USERNAME
server-password: OSSRH_TOKEN
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Substituted with the value stored in the referenced secret
gpg-passphrase: MAVEN_GPG_PASSPHRASE # Env var that holds the key's passphrase

- name: Cache Maven packages
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

# Runs the Maven command to publish to the `ossrh` repository.
# The `OSSRH_USERNAME` environment variable will be set with the contents of your `OSSRH_USERNAME` secret,
# and the `OSSRH_TOKEN` environment variable will be set with the contents of your `OSSRH_TOKEN` secret.
- name: Publish package
run: mvn --batch-mode deploy -Pmaven-central-publishing
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
42 changes: 0 additions & 42 deletions .github/workflows/tag_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,45 +69,3 @@ jobs:
asset_path: lib/ecocode-java-plugin-${{ github.ref_name }}.jar
asset_name: ecocode-java-plugin-${{ github.ref_name }}.jar
asset_content_type: application/zip
upload-php:
name: Upload PHP Plugin
runs-on: ubuntu-latest
needs: build
steps:
- name: Import plugin JAR files
id: import_jar_files
uses: actions/download-artifact@v3
with:
name: ecocode-plugins
path: lib
- name: Upload Release Asset - PHP Plugin
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{needs.build.outputs.upload_url}}
asset_path: lib/ecocode-php-plugin-${{ github.ref_name }}.jar
asset_name: ecocode-php-plugin-${{ github.ref_name }}.jar
asset_content_type: application/zip
upload-python:
name: Upload Python Plugin
runs-on: ubuntu-latest
needs: build
steps:
- name: Import plugin JAR files
id: import_jar_files
uses: actions/download-artifact@v3
with:
name: ecocode-plugins
path: lib
- name: Upload Release Asset - Python Plugin
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{needs.build.outputs.upload_url}}
asset_path: lib/ecocode-python-plugin-${{ github.ref_name }}.jar
asset_name: ecocode-python-plugin-${{ github.ref_name }}.jar
asset_content_type: application/zip
22 changes: 18 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
### Changed

- [#121](https://github.com/green-code-initiative/ecoCode/issues/121) new PHP rule : Multiple if-else statement + refactoring implementation
- [#216](https://github.com/green-code-initiative/ecoCode/issues/216) Upgrade rule EC2 for Java : Multiple if-else statement improvment
- [#106](https://github.com/green-code-initiative/ecoCode/issues/106) Upgrade RULES.md : rule EC67 not relevant neither for Python nor Rust
- [#225](https://github.com/green-code-initiative/ecoCode/pull/225) Upgrade licence system and licence headers of Java files

### Changed
### Deleted

## [1.4.0] - 2023-08-08

### Added

- [#205](https://github.com/green-code-initiative/ecoCode/issues/205) compatibility with SonarQube 10.1
- [#210](https://github.com/green-code-initiative/ecoCode/pull/210) Publish to Maven Central (module ecocode-rules-specifications)

### Deleted

- [#182](https://github.com/green-code-initiative/ecoCode/issues/182) Split repository : move Python module to new `ecoCode-python` repository
- [#182](https://github.com/green-code-initiative/ecoCode/issues/182) Split repository : move Php module to new `ecoCode-php` repository

## [1.3.1] - 2023-07-19

### Added
Expand Down Expand Up @@ -155,7 +167,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- First official release of ecocode plugins : java plugin, php plugin and python plugin

[unreleased]: https://github.com/green-code-initiative/ecoCode/compare/v1.3.1...HEAD
[unreleased]: https://github.com/green-code-initiative/ecoCode/compare/v1.4.0...HEAD

[1.4.0]: https://github.com/green-code-initiative/ecoCode/compare/v1.3.1...v1.4.0

[1.3.1]: https://github.com/green-code-initiative/ecoCode/compare/v1.3.0...v1.3.1

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ COPY . /usr/src/ecocode
WORKDIR /usr/src/ecocode
RUN ./tool_build.sh

FROM sonarqube:10.0.0-community
FROM sonarqube:10.1.0-community
COPY --from=builder /usr/src/ecocode/lib/* /opt/sonarqube/extensions/plugins/
20 changes: 6 additions & 14 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# Install notes

- [Common installation notes / requirements](#common-installation-notes--requirements)
- [Special points for Standard plugins](#special-points-for-standard-plugins)
- [Project structure](#project-structure)
- [Plugin-specific guides](#plugin-specific-guides)

Common installation notes / requirements
========================================
## Common installation notes / requirements

Please read common [INSTALL.md](https://github.com/green-code-initiative/ecoCode-common/blob/main/doc/INSTALL.md)
in `ecoCode-common` repository. Please follow the specific guides below for additional information on installing the
desired plugins.

Special points for Standard plugins
=================================
## Special points for Standard plugins

Project structure
-----------------
### Project structure

Here is a preview of project tree :

Expand All @@ -23,18 +22,11 @@ ecoCode # Root directory
|
+--java-plugin # JAVA
|
+--php-plugin # PHP
|
+--python-plugin # Python
|
\--docker-compose.yml # Docker compose file
```

You will find more information about the plugins’ architecture in their folders

Plugin-specific guides
----------------------
### Plugin-specific guides

- [Java how-to](java-plugin/README.md)
- [Python how-to](python-plugin/README.md)
- [PHP how-to](php-plugin/README.md)
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ refer to the contribution section.

- [Java](java-plugin/)
- [JavaScript](https://github.com/green-code-initiative/ecoCode-javascript)
- [PHP](php-plugin/)
- [Python](python-plugin/)
- [PHP](https://github.com/green-code-initiative/ecoCode-php)
- [Python](https://github.com/green-code-initiative/ecoCode-python)

![Screenshot](docs/resources/screenshot.PNG)

Expand Down Expand Up @@ -78,24 +78,26 @@ Ready to use binaries are available [from GitHub](https://github.com/green-code-

| Plugins Version | SonarQube version |
|------------------|-----------------------------|
| 0.1.+ | SonarQube 8.9.+ LTS to 9.3 |
| 0.2.+ | SonarQube 9.4.+ LTS to 9.9 |
| 1.0.+ | SonarQube 9.4.+ LTS to 9.9 |
| 1.1.+ | SonarQube 9.4.+ LTS to 9.9 |
| 1.2.+ | SonarQube 9.4.+ LTS to 10.0 |
| 1.4.+ | SonarQube 9.4.+ LTS to 10.1 |
| 1.3.+ | SonarQube 9.4.+ LTS to 10.0 |
| 1.2.+ | SonarQube 9.4.+ LTS to 10.0 |
| 1.1.+ | SonarQube 9.4.+ LTS to 9.9 |
| 1.0.+ | SonarQube 9.4.+ LTS to 9.9 |
| 0.2.+ | SonarQube 9.4.+ LTS to 9.9 |
| 0.1.+ | SonarQube 8.9.+ LTS to 9.3 |

☕ Plugin Java part compatibility
------------------

| Plugins Version | Java version |
|------------------|--------------|
| 0.1.+ | 11 / 17 |
| 0.2.+ | 11 / 17 |
| 1.0.+ | 11 / 17 |
| 1.1.+ | 11 / 17 |
| 1.2.+ | 11 / 17 |
| 1.4.+ | 11 / 17 |
| 1.3.+ | 11 / 17 |
| 1.2.+ | 11 / 17 |
| 1.1.+ | 11 / 17 |
| 1.0.+ | 11 / 17 |
| 0.2.+ | 11 / 17 |
| 0.1.+ | 11 / 17 |

🤝 Contribution
---------------
Expand Down Expand Up @@ -126,6 +128,7 @@ Then, if no answer, contact ...
- [Olivier Le Goaër](https://olegoaer.perso.univ-pau.fr)
- [Maxime DUBOIS](https://www.linkedin.com/in/maxime-dubois-%F0%9F%8C%B1-649a3a3/)
- [David DE CARVALHO](https://www.linkedin.com/in/david%E2%80%8E-de-carvalho-8b395284/)
- [Maxime MALGORN](https://www.linkedin.com/in/maximemalgorn/)

🧐 Core Team Emeriti
--------------------
Expand Down
2 changes: 1 addition & 1 deletion RULES.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Some are applicable for different technologies.
| EC7 | Rewrite native getter/setters | Overloading them lengthens the compilation and execution times of these methods, which are usually much better optimized by the language than by the developer. | [cnumr best practices (3rd edition) BP_062 (no longer exists in edition 4)](https://www.greenit.fr/2019/05/07/ecoconception-web-les-115-bonnes-pratiques-3eme-edition/) | 🚀 | 🚀 | 🚀 || 🚀 |
| EC63 | Unnecessarily assigning values to variables | Avoid declaring and using variables when it is not indis-thinkable. Indeed, each allocation corresponds to the RAM occupied. | [cnumr best practices (3rd edition) BP_063 (no longer exists in edition 4)](https://www.greenit.fr/2019/05/07/ecoconception-web-les-115-bonnes-pratiques-3eme-edition/) || 🚀 | 🚀 | 🚀 | 🚀 |
| EC66 | Use single quote (') instead of quotation mark (") | The shape using the quotation marks allows the developer to insert variables that will be substituted at run time. But if the string does not have a variable, use quotes instead. Thus, language will not look for variables to subtituture, which will reduce the consumption of CPU cycles. | [cnumr best practices (3rd edition) BP_066 (no longer exists in edition 4)](https://www.greenit.fr/2019/05/07/ecoconception-web-les-115-bonnes-pratiques-3eme-edition/) | 🚀 || 🚀 || 🚀 |
| EC67 | Use the $i++ variable during an iteration | The $i++ form has the disadvantage of generating a tem-porary variable during incrementation, which is not the case with the ++$i form. | [cnumr best practices (3rd edition) BP_067 (no longer exists in edition 4)](https://www.greenit.fr/2019/05/07/ecoconception-web-les-115-bonnes-pratiques-3eme-edition/) ||| 🚀 | 🚀 | 🚀 |
| EC67 | Use the $i++ variable during an iteration | The $i++ form has the disadvantage of generating a tem-porary variable during incrementation, which is not the case with the ++$i form. | [cnumr best practices (3rd edition) BP_067 (no longer exists in edition 4)](https://www.greenit.fr/2019/05/07/ecoconception-web-les-115-bonnes-pratiques-3eme-edition/) ||| 🚀 | 🚫 | 🚫 |
| EC69 | Calling a function in the declaration of a for loop | Avoid calling the function each time the loop is iterated. | [cnumr best practices (3rd edition) BP_069 (no longer exists in edition 4)](https://www.greenit.fr/2019/05/07/ecoconception-web-les-115-bonnes-pratiques-3eme-edition/) ||| 🚀 || 🚀 |
| EC72 | Perform an SQL query inside a loop | Servers are optimized to process multiple selections, insertions, or changes in a single query or transaction. consume CPU cycles, RAM, and bandwidth unnecessarily. | [cnumr best practices (3rd edition) BP_072](https://github.com/cnumr/best-practices/blob/main/chapters/BP_072_fr.md) ||| 🚀 || 🚀 |
| EC74 | Write SELECT * FROM | The database server must resolve the fields based on the schema. If you are familiar with the diagram, it is strongly recommended to name the fields. | [cnumr best practices (3rd edition) BP_074 (no longer exists in edition 4)](https://www.greenit.fr/2019/05/07/ecoconception-web-les-115-bonnes-pratiques-3eme-edition/) ||| 🚀 || 🚀 |
Expand Down
3 changes: 0 additions & 3 deletions TODOs_DDC.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ actions vues perso :
- nettoyer le MIGRATION_TODOs.md
- ménage dans les branches de dev (local et remote)
- JYC : suppression dépendance analyser-commons ==> check si bien tout nettoyé (version dans pom, référence dans code)
- créer issue sur la rule EC2 (`avoidMultipleIfElse`) sur JAVA :
- à refondre avec les uses cases du PHP + implem du PHP (en cours - PR_160_recup)
- JAVA : existe depuis longtemps !!! normal que l'implem PHP et python aient le même code minimaliste fonctionellement
- voir les rules désativées chez PJ, créer des issues et corriger (`avoidMultipleIfElse`) :
- voir pourquoi désactivées car ralaient trop
- retester le EC2
12 changes: 3 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3.3"
services:
sonar:
image: sonarqube:10.0.0-community
image: sonarqube:10.1.0-community
container_name: sonar_ecocode
ports:
- "9000:9000"
Expand All @@ -16,14 +16,8 @@ services:
SONAR_ES_BOOTSTRAP_CHECKS_DISABLE: 'true'
volumes:
- type: bind
source: ./java-plugin/target/ecocode-java-plugin-1.3.2-SNAPSHOT.jar
target: /opt/sonarqube/extensions/plugins/ecocode-java-plugin-1.3.2-SNAPSHOT.jar
- type: bind
source: ./php-plugin/target/ecocode-php-plugin-1.3.2-SNAPSHOT.jar
target: /opt/sonarqube/extensions/plugins/ecocode-php-plugin-1.3.2-SNAPSHOT.jar
- type: bind
source: ./python-plugin/target/ecocode-python-plugin-1.3.2-SNAPSHOT.jar
target: /opt/sonarqube/extensions/plugins/ecocode-python-plugin-1.3.2-SNAPSHOT.jar
source: ./java-plugin/target/ecocode-java-plugin-1.4.1-SNAPSHOT.jar
target: /opt/sonarqube/extensions/plugins/ecocode-java-plugin-1.4.1-SNAPSHOT.jar
- "extensions:/opt/sonarqube/extensions"
- "logs:/opt/sonarqube/logs"
- "data:/opt/sonarqube/data"
Expand Down
2 changes: 1 addition & 1 deletion ecocode-rules-specifications/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.ecocode</groupId>
<artifactId>ecocode-parent</artifactId>
<version>1.3.2-SNAPSHOT</version>
<version>1.4.1-SNAPSHOT</version>
</parent>

<artifactId>ecocode-rules-specifications</artifactId>
Expand Down
Loading

0 comments on commit 788fd55

Please sign in to comment.