Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-grofcik committed May 12, 2022
2 parents 9178957 + a0da3dc commit 5e54594
Show file tree
Hide file tree
Showing 46 changed files with 1,782 additions and 121 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,5 @@ hs_err_pid*
*.iml
*.ipr
*.iws
/crp-flowable-spock/target/
/crp-flowable-groovy/target/
/crp-flowable-shell/target/
/*/target/
/.idea/
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ before_script:
- echo MAVEN_OPTS=\"-Xmx2048m -Xms1024m -Djava.awt.headless=true\" > ~/.mavenrc
- chmod +x mvnw

script: ./mvnw verify -DskipTests=false -Pdocker -B
script: ./mvnw verify -DskipTests=false -Pintegration-test -B

deploy:
provider: script
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
# flowable-ex
# crp-flowable-ex

# gpg public key
```
-------------------------------------------------
pub ed25519 2022-05-05 [SC]
8F1F8EA5D80A19261D4225C151F1832CEE783D36
uid [ultimate] crystal-processes <[email protected]>
```
91 changes: 91 additions & 0 deletions crp-bpm-sonarqube-plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>crp-flowable-ex</artifactId>
<groupId>io.github.crystal-processes</groupId>
<version>0.0.4-SNAPSHOT</version>
</parent>

<artifactId>crp-bpm-sonarqube-plugin</artifactId>
<packaging>sonar-plugin</packaging>
<version>0.0.4-SNAPSHOT</version>

<name>BPM Sonarqube plugin</name>
<description>Business process management plugin for Sonarqube</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sonar.apiVersion>8.3.1.34397</sonar.apiVersion>
<jdk.min.version>1.8</jdk.min.version>
<sonar.sources>src/main/java</sonar.sources>
</properties>

<dependencies>
<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-plugin-api</artifactId>
<version>${sonar.apiVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<!-- packaged with the plugin -->
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>

<!-- unit tests -->
<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-testing-harness</artifactId>
<version>${sonar.apiVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.3.3</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
<artifactId>sonar-packaging-maven-plugin</artifactId>
<version>1.18.0.372</version>
<extensions>true</extensions>
<configuration>
<pluginKey>BPM</pluginKey>
<pluginClass>org.crp.sonarsource.plugins.bpm.BpmPlugin</pluginClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${jdk.min.version}</source>
<target>${jdk.min.version}</target>
</configuration>
</plugin>
<plugin>
<!-- UTF-8 bundles are not supported by Java, so they must be converted during build -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>native2ascii-maven-plugin</artifactId>
<version>2.0.1</version>
<executions>
<execution>
<goals>
<goal>resources</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.crp.sonarsource.plugins.bpm;

import org.crp.sonarsource.plugins.bpm.languages.BpmnLanguage;
import org.crp.sonarsource.plugins.bpm.languages.BpmnQualityProfile;
import org.crp.sonarsource.plugins.bpm.rules.BpmnCoverageLoaderSensor;
import org.crp.sonarsource.plugins.bpm.settings.BpmnLanguageProperties;
import org.sonar.api.Plugin;

/**
* Business process management plugin for sonarqube
*/
public class BpmPlugin implements Plugin {

@Override
public void define(Context context) {
context.addExtensions(BpmnLanguage.class, BpmnQualityProfile.class);
context.addExtensions(BpmnLanguageProperties.getProperties());

context
.addExtension(BpmnCoverageLoaderSensor.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.crp.sonarsource.plugins.bpm.languages;

import org.crp.sonarsource.plugins.bpm.settings.BpmnLanguageProperties;
import org.sonar.api.config.Configuration;
import org.sonar.api.resources.AbstractLanguage;

/**
* This class defines the bpmn language.
*/
public final class BpmnLanguage extends AbstractLanguage {

public static final String NAME = "BPMN";
public static final String KEY = "bpmn";

private final Configuration config;

public BpmnLanguage(Configuration config) {
super(KEY, NAME);
this.config = config;
}

@Override
public String[] getFileSuffixes() {
return config.getStringArray(BpmnLanguageProperties.FILE_SUFFIXES_KEY);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.crp.sonarsource.plugins.bpm.languages;

import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition;

/**
* Default, BuiltIn Quality Profile for the projects having bpmn files
*/
public final class BpmnQualityProfile implements BuiltInQualityProfilesDefinition {

@Override
public void define(Context context) {
NewBuiltInQualityProfile profile = context.createBuiltInQualityProfile("BPMN Rules", BpmnLanguage.KEY);
profile.setDefault(true);

profile.done();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package org.crp.sonarsource.plugins.bpm.languages;

public class ReportEvent {
protected String fileName;
protected String processDefinitionKey;
protected String flowElementId;
protected int lineNumber;
protected int hits;
protected String event;

private ReportEvent(String fileName, String processDefinitionKey, String flowElementId, int lineNumber, int hits, String event) {
this.fileName = fileName;
this.processDefinitionKey = processDefinitionKey;
this.flowElementId = flowElementId;
this.lineNumber = lineNumber;
this.hits = hits;
this.event = event;
}

public String getFileName() {
return fileName;
}

public String getProcessDefinitionKey() {
return processDefinitionKey;
}

public String getFlowElementId() {
return flowElementId;
}

public int getLineNumber() {
return lineNumber;
}

public String getEvent() {
return event;
}

public int getHits() {
return hits;
}

@Override
public String toString() {
return fileName + '|' +
processDefinitionKey + '|' +
flowElementId + '|' +
lineNumber + '|' +
hits + '|' +
event + '|';
}

public void addHit() {
hits++;
}

public void addHits(int hits) {
this.hits += hits;
}

public static class Builder {
protected String fileName;
protected String processDefinitionKey;
protected String flowElementId;
protected int lineNumber = -1;
protected int hits = 0;
protected String event;

public Builder() {
}

public Builder fileName(String fileName) {
this.fileName = fileName;
return this;
}

public Builder processDefinitionKey(String processDefinitionKey) {
this.processDefinitionKey = processDefinitionKey;
return this;
}

public Builder flowElementId(String flowElementId) {
this.flowElementId = flowElementId;
return this;
}

public Builder lineNumber(int lineNumber) {
this.lineNumber = lineNumber;
return this;
}

public Builder event(String event) {
this.event = event;
return this;
}

public ReportEvent build() {
return new ReportEvent(fileName, processDefinitionKey, flowElementId, lineNumber, hits, event);
}
public static ReportEvent build(String eventCSV) {
String[] eventCSVArray = eventCSV.split("\\|");
return new ReportEvent(eventCSVArray[0], eventCSVArray[1], eventCSVArray[2], Integer.parseInt(eventCSVArray[3]), Integer.parseInt(eventCSVArray[4]), "");
}
}
}
Loading

0 comments on commit 5e54594

Please sign in to comment.