cnumr / ecocode Goto Github PK
View Code? Open in Web Editor NEWReduce the environmental footprint of your software applications with this cutting-edge sonarQube plugin
License: GNU General Public License v3.0
Reduce the environmental footprint of your software applications with this cutting-edge sonarQube plugin
License: GNU General Public License v3.0
Dear ecoCode maintainers,
I noticed that currently the pom.xml files in modules android-plugin and codenarc-converter are referencing codenarc 2.2.3 - however on Maven central the latest available 2.x version is 2.2.0
BR Christina
Je découvre votre outils et j'ai quelques questions :
Merci
Hello,
Après avoir build le jar, je lance le docker compose mais pendant le lancement du container sonarqube, j'ai cette erreur :
2022.11.04 09:21:10 WARN web[][o.s.c.a.AnnotationConfigApplicationContext] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@277050dc-org.sonar.server.rule.RegisterRules': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/sonar/java/JavaVersionAwareVisitor
2022.11.04 09:21:10 ERROR web[][o.s.s.p.Platform] Background initialization failed. Stopping SonarQube
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@277050dc-org.sonar.server.rule.RegisterRules': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/sonar/java/JavaVersionAwareVisitor
Précédé par ce log un peu plus haut :
INFO web[][o.s.s.p.ServerPluginManager] Deploy ecoCode Java Sonar Plugin / 1.0.0-SNAPSHOT / null
J'ai bien essayer de changer la version java pour build le jar mais rien n'y fait :/
Holla,
Il est déclaré dans le projet la dépendance codeNarc en version 2.2.1 . Cette librairie n'existe pas/plus sur maven repository et empêche la construction du projet. Il faudrait soit downgrade en 2.2.0 ou upgrade en 3.0.0
Ref : https://mvnrepository.com/artifact/org.codenarc/CodeNarc
Je n'ai pas eu le temps de tester la modification à cause de la différenciation d'outillage Gradle vs Maven sur le module codenarc-converter.
Hi,
Having next week bad experience with a plugin, i'm verifying viability for the next sonarqube LTS v9 of this plugin.
What is the error?
Can't integrate the php-plugin with my docker image sonarqube v9 (latest, 9.4-community). Hard stopping process.
Complete log after Sonarqube DBmigration :
2022.05.17 12:59:41 INFO web[][o.s.s.p.Platform] Database has been automatically updated
2022.05.17 12:59:41 INFO web[][o.s.s.p.w.MasterServletFilter] Initializing servlet filter org.sonar.server.platform.web.WebServiceFilter@3b95bf70 [pattern=UrlPattern{inclusions=[/api/system/migrate_db.*, ...], exclusions=[/api/components/update_key, ...]}]
2022.05.17 12:59:41 INFO web[][o.s.s.p.DetectPluginChange] Detect plugin changes
2022.05.17 12:59:41 INFO web[][o.s.s.a.EmbeddedTomcat] HTTP connector enabled on port 9000
2022.05.17 12:59:45 INFO web[][o.s.s.e.IndexCreator] Create index [metadatas]
2022.05.17 12:59:45 INFO es[][o.e.c.m.MetadataCreateIndexService] [metadatas] creating index, cause [api], templates [], shards [1]/[0]
2022.05.17 12:59:46 INFO es[][o.e.c.r.a.AllocationService] Cluster health status changed from [YELLOW] to [GREEN] (reason: [shards started [[metadatas][0]]]).
2022.05.17 12:59:46 INFO web[][o.s.s.e.IndexCreator] Create type metadatas/metadata
2022.05.17 12:59:46 INFO es[][o.e.c.m.MetadataMappingService] [metadatas/9rEnPWfERAKrvD7dw-VZWg] create_mapping [metadata]
2022.05.17 12:59:46 INFO web[][o.s.s.e.IndexCreator] Create index [components]
2022.05.17 12:59:47 INFO es[][o.e.c.m.MetadataCreateIndexService] [components] creating index, cause [api], templates [], shards [5]/[0]
2022.05.17 12:59:47 INFO es[][o.e.c.r.a.AllocationService] Cluster health status changed from [YELLOW] to [GREEN] (reason: [shards started [[components][4]]]).
2022.05.17 12:59:47 INFO web[][o.s.s.e.IndexCreator] Create type components/auth
2022.05.17 12:59:47 INFO es[][o.e.c.m.MetadataMappingService] [components/2678K1ioQFi8HB-hNuzAKA] create_mapping [auth]
2022.05.17 12:59:47 INFO web[][o.s.s.e.IndexCreator] Create index [projectmeasures]
2022.05.17 12:59:47 INFO es[][o.e.c.m.MetadataCreateIndexService] [projectmeasures] creating index, cause [api], templates [], shards [5]/[0]
2022.05.17 12:59:48 INFO es[][o.e.c.r.a.AllocationService] Cluster health status changed from [YELLOW] to [GREEN] (reason: [shards started [[projectmeasures][4]]]).
2022.05.17 12:59:48 INFO web[][o.s.s.e.IndexCreator] Create type projectmeasures/auth
2022.05.17 12:59:48 INFO es[][o.e.c.m.MetadataMappingService] [projectmeasures/Mw5_fEmERl2uObkR1YMk-A] create_mapping [auth]
2022.05.17 12:59:48 INFO web[][o.s.s.e.IndexCreator] Create index [rules]
2022.05.17 12:59:48 INFO es[][o.e.c.m.MetadataCreateIndexService] [rules] creating index, cause [api], templates [], shards [2]/[0]
2022.05.17 12:59:48 INFO es[][o.e.c.r.a.AllocationService] Cluster health status changed from [YELLOW] to [GREEN] (reason: [shards started [[rules][0]]]).
2022.05.17 12:59:48 INFO web[][o.s.s.e.IndexCreator] Create type rules/rule
2022.05.17 12:59:48 INFO es[][o.e.c.m.MetadataMappingService] [rules/5qry3c5gSyqgOBS54vrFAw] create_mapping [rule]
2022.05.17 12:59:48 INFO web[][o.s.s.e.IndexCreator] Create index [issues]
2022.05.17 12:59:49 INFO es[][o.e.c.m.MetadataCreateIndexService] [issues] creating index, cause [api], templates [], shards [5]/[0]
2022.05.17 12:59:49 INFO es[][o.e.c.r.a.AllocationService] Cluster health status changed from [YELLOW] to [GREEN] (reason: [shards started [[issues][4]]]).
2022.05.17 12:59:49 INFO web[][o.s.s.e.IndexCreator] Create type issues/auth
2022.05.17 12:59:49 INFO es[][o.e.c.m.MetadataMappingService] [issues/1lsGB86nQZC9QkqvwfwqJA] create_mapping [auth]
2022.05.17 12:59:49 INFO web[][o.s.s.e.IndexCreator] Create index [users]
2022.05.17 12:59:49 INFO es[][o.e.c.m.MetadataCreateIndexService] [users] creating index, cause [api], templates [], shards [1]/[0]
2022.05.17 12:59:49 INFO es[][o.e.c.r.a.AllocationService] Cluster health status changed from [YELLOW] to [GREEN] (reason: [shards started [[users][0]]]).
2022.05.17 12:59:49 INFO web[][o.s.s.e.IndexCreator] Create type users/user
2022.05.17 12:59:49 INFO es[][o.e.c.m.MetadataMappingService] [users/o8ZhF-9ZS1G4nR-jgU8IOg] create_mapping [user]
2022.05.17 12:59:50 INFO web[][o.s.s.e.IndexCreator] Create index [views]
2022.05.17 12:59:50 INFO es[][o.e.c.m.MetadataCreateIndexService] [views] creating index, cause [api], templates [], shards [5]/[0]
2022.05.17 12:59:50 INFO es[][o.e.c.r.a.AllocationService] Cluster health status changed from [YELLOW] to [GREEN] (reason: [shards started [[views][4]]]).
2022.05.17 12:59:50 INFO web[][o.s.s.e.IndexCreator] Create type views/view
2022.05.17 12:59:50 INFO es[][o.e.c.m.MetadataMappingService] [views/aIWnkO9gTeizMYWVVIkrng] create_mapping [view]
2022.05.17 12:59:50 INFO web[][o.s.s.s.LogServerId] Server ID: 147B411E-AYDSGlCzN2IJeyhYUNKM
2022.05.17 12:59:50 WARN web[][o.s.s.a.LogOAuthWarning] For security reasons, OAuth authentication should use HTTPS. You should set the property 'Administration > Configuration > Server base URL' to a HTTPS URL.
2022.05.17 12:59:50 INFO web[][o.s.s.p.UpdateCenterClient] Update center: https://update.sonarsource.org/update-center.properties (no proxy)
2022.05.17 12:59:53 WARN web[][o.s.a.s.w.WebService$Action] The response example is not set on action api/system/liveness
2022.05.17 12:59:53 WARN web[][o.s.a.s.w.WebService$Action] The response example is not set on action api/plugins/download
2022.05.17 12:59:53 WARN web[][o.s.a.s.w.WebService$Action] The response example is not set on action api/analysis_cache/get
2022.05.17 12:59:53 WARN web[][o.s.a.s.w.WebService$Action] The response example is not set on action api/alm_integrations/list_bitbucketserver_projects
2022.05.17 12:59:53 WARN web[][o.s.a.s.w.WebService$Action] The response example is not set on action api/alm_integrations/search_bitbucketcloud_repos
2022.05.17 12:59:53 WARN web[][o.s.a.s.w.WebService$Action] The response example is not set on action api/alm_integrations/check_pat
2022.05.17 12:59:53 WARN web[][o.s.a.s.w.WebService$Action] The response example is not set on action api/alm_integrations/list_azure_projects
2022.05.17 12:59:53 WARN web[][o.s.a.s.w.WebService$Action] The response example is not set on action api/alm_integrations/search_bitbucketserver_repos
2022.05.17 12:59:53 WARN web[][o.s.a.s.w.WebService$Action] The response example is not set on action api/alm_integrations/search_azure_repos
2022.05.17 12:59:53 WARN web[][o.s.a.s.w.WebService$Action] The response example is not set on action api/project_dump/status
2022.05.17 12:59:53 WARN web[][o.s.a.s.w.WebService$Action] The response example is not set on action api/push/sonarlint_events
2022.05.17 12:59:53 INFO web[][o.s.s.a.p.ExpiredSessionsCleaner] Purge of expired session tokens has removed 0 elements
2022.05.17 12:59:53 INFO web[][o.s.s.a.p.ExpiredSessionsCleaner] Purge of expired SAML message ids has removed 0 elements
2022.05.17 12:59:53 INFO web[][o.s.s.n.NotificationDaemon] Notification service started (delay 60 sec.)
2022.05.17 12:59:53 INFO web[][o.s.s.t.TelemetryDaemon] Sharing of SonarQube statistics is enabled.
2022.05.17 12:59:54 INFO web[][o.s.s.s.GeneratePluginIndex] Generate scanner plugin index
2022.05.17 12:59:54 INFO web[][o.s.s.s.RegisterMetrics] Register metrics
2022.05.17 12:59:54 INFO web[][o.s.s.q.RegisterQualityGates] Built-in quality gate's conditions of [Sonar way] has been updated
2022.05.17 12:59:54 INFO web[][o.s.s.r.RegisterRules] Register rules
2022.05.17 12:59:55 WARN web[][o.s.c.a.AnnotationConfigApplicationContext] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@277050dc-org.sonar.server.rule.RegisterRules': Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: 'void org.sonarsource.analyzer.commons.RuleMetadataLoader.<init>(java.lang.String)'
2022.05.17 12:59:55 ERROR web[][o.s.s.p.Platform] Background initialization failed. Stopping SonarQube
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@277050dc-org.sonar.server.rule.RegisterRules': Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: 'void org.sonarsource.analyzer.commons.RuleMetadataLoader.<init>(java.lang.String)'
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:628)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:187)
at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:80)
at org.sonar.server.platform.platformlevel.PlatformLevelStartup.access$001(PlatformLevelStartup.java:51)
at org.sonar.server.platform.platformlevel.PlatformLevelStartup$1.doPrivileged(PlatformLevelStartup.java:119)
at org.sonar.server.user.DoPrivileged.execute(DoPrivileged.java:45)
at org.sonar.server.platform.platformlevel.PlatformLevelStartup.start(PlatformLevelStartup.java:116)
at org.sonar.server.platform.PlatformImpl.executeStartupTasks(PlatformImpl.java:183)
at org.sonar.server.platform.PlatformImpl$1.lambda$doRun$1(PlatformImpl.java:107)
at org.sonar.server.platform.PlatformImpl$AutoStarterRunnable.runIfNotAborted(PlatformImpl.java:344)
at org.sonar.server.platform.PlatformImpl$1.doRun(PlatformImpl.java:107)
at org.sonar.server.platform.PlatformImpl$AutoStarterRunnable.run(PlatformImpl.java:328)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.NoSuchMethodError: 'void org.sonarsource.analyzer.commons.RuleMetadataLoader.<init>(java.lang.String)'
at fr.cnumr.php.MyPhpRules.define(MyPhpRules.java:64)
at org.sonar.server.rule.RuleDefinitionsLoader.load(RuleDefinitionsLoader.java:56)
at org.sonar.server.rule.RegisterRules.start(RegisterRules.java:119)
at org.sonar.core.platform.StartableBeanPostProcessor.postProcessBeforeInitialization(StartableBeanPostProcessor.java:33)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:440)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
... 20 common frames omitted
2022.05.17 12:59:55 INFO web[][o.s.p.ProcessEntryPoint] Hard stopping process
2022.05.17 12:59:55 INFO web[][o.s.s.n.NotificationDaemon] Notification service stopped
2022.05.17 12:59:55 INFO web[][o.s.s.p.d.EmbeddedDatabase] Embedded database stopped
2022.05.17 12:59:55 INFO app[][o.s.a.SchedulerImpl] Process[Web Server] is stopped
2022.05.17 12:59:55 INFO app[][o.s.a.SchedulerImpl] Process[ElasticSearch] is stopped
2022.05.17 12:59:55 WARN app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [ElasticSearch]: 143
2022.05.17 12:59:55 INFO app[][o.s.a.SchedulerImpl] SonarQube is stopped
How to reproduce ?
Dockerfile
FROM sonarqube:9.4-community
COPY --chown=sonarqube:sonarqube ecocode-php* ${SQ_EXTENSIONS_DIR}/plugins/
CMD ["/opt/sonarqube/bin/sonar.sh"]
docker image build -f Dockerfile -t sonarqube:9-4-ecocode .
docker run -p 9000:9000 sonarqube:9-4-ecocode
More info
No problem with python-plugin and java-plugin.
But have to verify integration rules with sonarlint.
RTE (via Mathilde) worked on the plugin at the beginning of the project.
Here are the sources of the internal RTE project given back to us to merge on ecoCode project and graciously donated to the open source community.
eslint-plugin-greenit-master.zip
stylelint-config-greenit-master.zip
htmlhint-sonarqube-master.zip
Check, Analyse, and merge code that is not already existing in ecoCode and ecoLinter
Check if follows are possible programmatically within ecocode plugin :
Check if the following rule is related to js and ts only and update documentation
Concerning the following rule : Using strings as arguments to SetTimeout() and setInterval()
I think this rule can be applied only to js/ts.
Check and update documentation
Originally posted by @glalloue in #67 (comment)
When trying to install the npm package, it's not found:
$ npm i eslint --save-dev
npm ERR! 404 Not Found - GET http://registry.npmjs.org/eslint-plugin-greenit - Not found
I am trying to install ecocode on my environement.
I installed the plugins and i can confirm that the number of rules increased for JAVA , PHP and Python
But when i try to manage the quality gate and quality profile i can't see them at all
Sonarqube version: Community EditionVersion 8.9.9 (build 56886) running on Docker container .
Is there anyone who can help me on this please ?
Thanks.
Use single quote (') instead of quotation mark (") is a common rule used in javascript / typescript
After some researches, it turns out that it is indeed not valid for java :
Use single quotes for literal chars, double quotes for literal Strings
https://stackoverflow.com/questions/439485/is-there-a-difference-between-single-and-double-quotes-in-java
With PHP, the rule seems to be different :
A single-quoted string does not have variables within it interpreted. A double-quoted string does.
https://stackoverflow.com/questions/3446216/what-is-the-difference-between-single-quoted-and-double-quoted-strings-in-php#:~:text=In%20PHP%2C%20people%20use%20single,b%20%24c%20%24d%22%20.
With python, it doesn't seem to matter
String literals can be enclosed in matching single quotes (') or double quotes (").
https://stackoverflow.com/questions/56011/single-quotes-vs-double-quotes-in-python
And Rust is similar to java
==> We need to update to applicable rules table
Originally posted by @glalloue in #67 (comment)
Hi,
I don't understand the recommandation concerning the rule cnumr-java:S53 (https://github.com/cnumr/ecoCode/blob/main/src/java-plugin/src/main/java/fr/cnumr/java/checks/UseCorrectForLoop.java)
Is it possible to access to the research paper regarding this rule (benchmark, java byte code analysis ...) ?
What are the experimental conditions ? Does the tests have been run on Android only, or does the tests have been on a server on Linux ?
Hi,
I'm look since few weeks the project and i have identified a recent renaming that i'm not agreed. I'm hoping my remark will be accepted/appreciated :)
You are using maven structure. The parent folder src is not appropriate. By convention, we're expected a pom together with a src folder.
And inside the pom, we are expected a ProjectName or Artifactid equal to the name folder (WYSIWYG).
More info and schema expected : wikipedia Maven
It will be more efficiency to rename as "ecocode" the src parent folder or any suggestion idea you have in mind. :)
Originally posted by @Silicoman in #72
The project is licensed as GPL-3 which does not permit to use it in Sonarqube which is licensed under LGPL-3.0.
Refs:
The fact that CodeNarc code project, which has an Apache-2.0 license, is included in the repository could also be a problem.
Ref: https://www.apache.org/licenses/GPL-compatibility.html
My reco:
Switch ecoCode plugins to LGPL-3.0 and preferably upstream modifications to CodeNarc or fork it as a separate project if not possible
regards,
Nicolas
Hello,
It looks like there is a dependency issue related to org.eclipse.jtd.core from what I could find on internet.
the solution which worked for me was to patch my local maven repository :
cp -r .m2/org/osgi/org.osgi.service.prefs/* .m2/org/osgi/service/org.osgi.service.prefs/
Hi
We observe a stack during analysis
Sonar 9.4
Maven 3.8.6
sonar-maven-plugin 3.8.0.2131
Java 18
[ERROR] Unable to run check class fr.cnumr.java.checks.UnnecessarilyAssignValuesToVariables - S63 on file 'fr/cnumr/java/sample/pdf/commons/Item.java', To help improve the SonarSource Java Analyzer, please report this problem to SonarSource: see https://community.sonarsource.com/
java.lang.NullPointerException: Cannot invoke "Object.toString()" because the return value of "org.sonar.plugins.java.api.tree.ReturnStatementTree.expression()" is null
at fr.cnumr.java.checks.UnnecessarilyAssignValuesToVariables$CheckUseVariableVisitor.visitReturnStatement(UnnecessarilyAssignValuesToVariables.java:152)
at org.sonar.java.model.statement.ReturnStatementTreeImpl.accept(ReturnStatementTreeImpl.java:70)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:40)
`package fr.cnumr.java.sample.pdf.commons.template;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import fr.cnumr.java.sample.pdf.commons.engine.Document;
import fr.cnumr.java.sample.pdf.commons.template.*;
import fr.cnumr.java.sample.pdf.commons.template.enums.Alignment;
import fr.cnumr.java.sample.pdf.commons.template.enums.Display;
import fr.cnumr.java.sample.pdf.commons.template.enums.ItemType;
import fr.cnumr.java.sample.pdf.commons.template.enums.Positioning;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static com.google.common.collect.Lists.newArrayList;
import static fr.cnumr.java.sample.pdf.commons.template.enums.Alignment.NONE;
import static fr.cnumr.java.sample.pdf.commons.template.enums.Alignment.TOP_LEFT;
import static fr.cnumr.java.sample.pdf.commons.template.enums.Display.ALWAYS;
import static fr.cnumr.java.sample.pdf.commons.template.enums.Positioning.ABSOLUTE;
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", visible = true)
@JsonSubTypes({ @JsonSubTypes.Type(value = Box.class, name = "BOX"), @JsonSubTypes.Type(value = Break.class, name = "BREAK"),
@JsonSubTypes.Type(value = Cab2d.class, name = "CAB2D"), @JsonSubTypes.Type(value = Circle.class, name = "CIRCLE"),
@JsonSubTypes.Type(value = Field.class, name = "FIELD"), @JsonSubTypes.Type(value = Image.class, name = "IMAGE"),
@JsonSubTypes.Type(value = Label.class, name = "LABEL"), @JsonSubTypes.Type(value = Line.class, name = "LINE"),
@JsonSubTypes.Type(value = ListItems.class, name = "LIST"), @JsonSubTypes.Type(value = Page.class, name = "PAGE"),
@JsonSubTypes.Type(value = Rectangle.class, name = "RECTANGLE"), @JsonSubTypes.Type(value = Segment.class, name = "SEGMENT"),
@JsonSubTypes.Type(value = Text.class, name = "TEXT"),@JsonSubTypes.Type(value = ConcatenatedFields.class, name = "CONCATENATED_FIELDS") })
public abstract class Item {
private String id;
private ItemType type;
protected Display display = ALWAYS;
protected List<String> conditions = newArrayList();
protected Position position = new Position();
protected Size size = new Size();
@JsonIgnore
private boolean drawable;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public ItemType getType() {
return type;
}
public void setType(ItemType type) {
this.type = type;
}
public Display getDisplay() {
return display;
}
public void setDisplay(Display display) {
this.display = display;
}
public List<String> getConditions() {
return conditions;
}
public void setConditions(List<String> conditions) {
this.conditions = conditions;
}
public Position getPosition() {
return position;
}
public void setPosition(Position position) {
this.position = position;
}
public Size getSize() {
return size;
}
public void setSize(Size size) {
this.size = size;
}
public boolean isDrawable() {
return drawable;
}
public void setDrawable(boolean drawable) {
this.drawable = drawable;
}
public abstract void draw(Document document, Optional<Box> parent, Optional<Item> previous) throws IOException;
public abstract void initItem(Document document, Optional<Box> parent, Optional<Item> previous) throws IOException;
/**
* Permet d'initialiser un élément dans un document.
*
* @param document : document auquel est rattaché l'élément.
* @param parent : boîte parente qui contient l'élément à initialiser.
* @param previous : élément précédent l'élément à initialiser.
* @throws IOException
*/
public void init(Document document, Optional<Box> parent, Optional<Item> previous) throws IOException {
initItem(document, parent, previous);
drawable = isDrawable(document.getValues());
}
/**
* Permet de calculer les coordonnées en points de l'élément en fonction de la boîte parente et de l'élément précédent.
*
* @param parent : boîte parente qui contient l'élément à initialiser.
* @param previous : élément précédent l'élément à initialiser.
*/
public void calculateCoordinates(Optional<Box> parent, Optional<Item> previous) {
Alignment alignment = position.getAlignment();
Positioning positioning = position.getPositioning();
float x = 0, y = 0;
if (alignment == NONE) {
if (previous.isEmpty() && positioning != ABSOLUTE) {
position.setAlignment(TOP_LEFT);
position.setPositioning(ABSOLUTE);
calculateCoordinates(parent, previous);
return;
}
Item i = previous.orElse(null);
x = positioning.getX(this, i);
y = positioning.getY(this, i);
} else {
if (parent.isEmpty()) {
return;
}
Box b = parent.get();
x = alignment.getX(this, b);
y = alignment.getY(this, b);
}
// Set text coordinates calculated above
position.setX(x);
position.setY(y);
}
/**
* Permet de définir si un élément est dessinable en fonction de conditions d'affichage.
*
* @param values : liste des couples clé/valeur qui permettent de renseigner le document.
* @return
*/
public boolean isDrawable(Map<String, String> values) {
return display.check(conditions, values);
}
}
`
Java 8 is almost dead, long live Java 11 (even if Java 17 is already out).
Migrating plugins to Java 11 should be a good idea, as Sonarqube server already use Java 11 (https://docs.sonarqube.org/latest/requirements/requirements/).
(Not authorize to add label enhancement)
The rule "The variable value is not assigned" (JAVA) can report false positives.
For example :
private void test() {
Object value = getValue ();
if (value instanceof String stringValue)
{
Logger.getLogger("this is a String : " + stringValue);
}
if (value instanceof Integer intValue)
{
Logger.getLogger("this is a Integer : " + intValue);
}
}
In this case, the variable is indeed used in the condition, and is then cast.
Hi
This page expose only the android java rules
https://www.ecocode.io/rules
But we have found and used other java rules that applies to java backend
https://github.com/cnumr/ecoCode/tree/main/src/java-plugin/src/main/java/fr/cnumr/java/checks
I am trying to install ecocode on my environement, but i can't build CodeNarc.
I proceeded the ./prepare-codenarc step correctly (I suppose).
But when I do the mvn clean install I got this error :
Could not resolve dependencies for project fr.cnumr:sonar-codenarc-converter:jar:1.0.0-SNAPSHOT: org.codenarc:CodeNarc:jar:2.2.2 was not found in https://repo.maven
.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced
Is someone could help me on this please ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.