Skip to content

Commit

Permalink
Adding checkstyle reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaland committed Nov 12, 2024
1 parent 3e03ba1 commit ee95b9c
Show file tree
Hide file tree
Showing 20 changed files with 191 additions and 125 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/reporting.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish Report

on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
publish_report:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up JDK 21
uses: actions/setup-java@v2
with:
java-version: '21'
distribution: 'adopt'

- name: Build and generate report
run: |
mvn clean install
mvn site
- name: Publish report
uses: actions/upload-artifact@v2
with:
name: Report
path: target/site
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ We need to figure out a better way to handel this in the future (or put this on

Linting is does using checkstyle and a slightly modified version of the [Google Java Style guide](https://google.github.io/styleguide/javaguide.html).

Run `mvn checkstyle:check -Dcheckstyle.config.location=checkstyle.xml`

### OWasp Security Scanning

The [OWASP Dependency-Check Plugin](https://owasp.org/www-project-dependency-check/) can be run using the following command:
Expand Down
8 changes: 5 additions & 3 deletions checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC "-//Puppy Crawl//DTD Suppressions 1.1//EN" "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>
<suppress checks=".*" files=".*Response.java"/>
<suppress checks=".*" files=".*Request.java"/>
<suppress checks=".*" files=".*Entity.java"/>
<suppress checks=".*" files=".*Response.java"/>
<suppress checks=".*" files=".*Request.java"/>
<suppress checks=".*" files=".*Entity.java"/>
<suppress checks=".*" files="WeaviateEmbeddingStoreCustom.java"/>
<suppress checks=".*" files="target/*"/>
</suppressions>
10 changes: 9 additions & 1 deletion checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
To suppress certain violations please review suppression filters.
Authors: Max Vetrenko, Mauryan Kansara, Ruslan Diachenko, Roman Ivanov.
See: https://github.com/checkstyle/checkstyle/blob/checkstyle-10.20.1/src/main/resources/google_checks.xml
-->

<module name="Checker">

<property name="charset" value="UTF-8"/>

<property name="severity" value="${org.checkstyle.google.severity}" default="warning"/>
<property name="severity" value="${org.checkstyle.google.severity}" default="error"/>

<property name="fileExtensions" value="java, properties, xml"/>
<!-- Excludes all 'module-info.java' files -->
Expand Down Expand Up @@ -309,6 +312,11 @@
<module name="OverloadMethodsDeclarationOrder"/>
<module name="ConstructorsDeclarationGrouping"/>
<module name="VariableDeclarationUsageDistance"/>
<!-- <module name="CustomImportOrder">
<property name="separateLineBetweenGroups" value="true"/>
<property name="customImportOrderRules" value="STATIC###THIRD_PARTY_PACKAGE"/>
<property name="tokens" value="IMPORT, STATIC_IMPORT, PACKAGE_DEF"/>
</module> -->
<module name="MethodParamPad">
<property name="tokens"
value="CTOR_DEF, LITERAL_NEW, METHOD_CALL, METHOD_DEF, CTOR_CALL,
Expand Down
61 changes: 40 additions & 21 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<quarkus.langchain4j.version>0.21.0.CR1</quarkus.langchain4j.version>
<org.mapstruct.version>1.6.2</org.mapstruct.version>
<owasp-dependency-check-plugin.version>11.1.0</owasp-dependency-check-plugin.version>
<maven-checkstyle-plugin.version>3.6.0</maven-checkstyle-plugin.version>
<checkstyle-maven-plugin.version>3.6.0</checkstyle-maven-plugin.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -142,6 +142,24 @@
</dependencies>

<build>

<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.6.0</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>10.20.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<groupId>${quarkus.platform.group-id}</groupId>
Expand Down Expand Up @@ -194,7 +212,25 @@
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>
</plugin>

<!-- Checkstyle Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle-maven-plugin.version}</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -236,23 +272,6 @@
</suppressionFiles>
</configuration>
</plugin>
<!-- Checkstyle Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle-maven-plugin.version}</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<suppressionsLocation>suppressions.xml</suppressionsLocation>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Expand All @@ -263,10 +282,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
<version>${checkstyle-maven-plugin.version}</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<suppressionsLocation>suppressions.xml</suppressionsLocation>
<suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation>
</configuration>
</plugin>
</plugins>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/redhat/composer/api/AssistantAdminApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class AssistantAdminApi {
@POST
@Path("llm")
public LlmConnectionEntity createLlm(LLMRequest request) {
return assistantService.createLLMConnection(request);
return assistantService.createLlmConnection(request);
}

/**
Expand All @@ -45,7 +45,7 @@ public LlmConnectionEntity createLlm(LLMRequest request) {
@GET
@Path("llm")
public List<LlmConnectionEntity> getLlms() {
return assistantService.getLLMConnections();
return assistantService.getLlmConnections();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/redhat/composer/api/EmbeddingApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ public class EmbeddingApi {
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public String embeddString(String text, @PathParam("embeddingType") String embeddingType) {
return embeddingService.embedding(text,embeddingType).toString();
return embeddingService.embedding(text, embeddingType).toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
@Path("/retriver")
@Authenticated
public class VectorRetriverAPI {
public class VectorRetriverApi {

@Inject
RetrieveService retrieveService;
Expand All @@ -39,7 +39,7 @@ public class VectorRetriverAPI {
public List<SourceResponse> retrieveSources(RetrieverRequest request,
@QueryParam("message") String message) {
return retrieveService.retrieveContent(request, message).stream()
.map(VectorRetriverAPI::toSourceResponse).toList();
.map(VectorRetriverApi::toSourceResponse).toList();
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.redhat.composer.api.validation;

import java.util.Map;
import java.util.Set;

import io.quarkus.security.Authenticated;
Expand All @@ -9,9 +8,12 @@
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;

/**
* OIDCValidationAPI.
*/
@Path("/auth")
@Authenticated
public class OIDCValidationAPI {
public class OidcValidationApi {

@Inject
SecurityIdentity securityIdentity;
Expand All @@ -26,7 +28,7 @@ public String getPrincipal() {

@GET
@Path("roles")
public Set getRoles() {
public Set<String> getRoles() {
return securityIdentity.getRoles();
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* Base AI Service Interface.
*/
public interface BaseAiService{
public interface BaseAiService {

/**
* Returns TokenStream given input.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
import io.smallrye.mutiny.Multi;

/**
* Mistral7BAiService
* Mistral7BAiService.
*/

public interface HealthCareService extends BaseAiService {

static final String systemMessage = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class OpenAiStreamingModel extends StreamingBaseModel {

Logger log = Logger.getLogger(WeaviateContentRetrieverClient.class);

@ConfigProperty( name = "openai.default.url")
@ConfigProperty(name = "openai.default.url")
private String mistralDefaultUrl;

@ConfigProperty(name = "openai.default.apiKey")
Expand All @@ -31,28 +31,35 @@ public class OpenAiStreamingModel extends StreamingBaseModel {
@ConfigProperty(name = "openai.default.temp")
private double openaiDefaultTemp;


/**
* Get the Chat Model.
* @param request the LLMRequest
* @return the StreamingChatLanguageModel
*/
public StreamingChatLanguageModel getChatModel(LLMRequest request) {
log.info("Attempting to create OpenAI Streaming Chat Model at: " + request.getUrl() + " with model name: " + request.getModelName());

log.info("Attempting to create OpenAI Streaming Chat Model at: " + request.getUrl()
+ " with model name: " + request.getModelName());

OpenAiStreamingChatModelBuilder builder = OpenAiStreamingChatModel.builder();
builder.baseUrl(request.getUrl() == null ? mistralDefaultUrl : request.getUrl());
builder.apiKey(request.getApiKey() == null ? mistralDefaultApiKey : request.getApiKey());

builder.modelName(request.getModelName() == null ? mistralDefaultModelName : request.getModelName());

// TODO: Add all the following to the request
builder.temperature(openaiDefaultTemp);
// TODO: Fill all this out
// if (modelName != null) {
// builder.modelName(modelName);
// }
// if (maxTokens != null) {
// builder.maxTokens(maxTokens);
// }
// if (safePrompt != null) {
// builder.safePrompt(safePrompt);
// }
builder.baseUrl(request.getUrl() == null ? mistralDefaultUrl : request.getUrl());
builder.apiKey(request.getApiKey() == null ? mistralDefaultApiKey : request.getApiKey());

builder.modelName(request.getModelName() == null ? mistralDefaultModelName : request.getModelName());

// TODO: Add all the following to the request
builder.temperature(openaiDefaultTemp);

// TODO: Fill all this out
// if (modelName != null) {
// builder.modelName(modelName);
// }
// if (maxTokens != null) {
// builder.maxTokens(maxTokens);
// }
// if (safePrompt != null) {
// builder.safePrompt(safePrompt);
// }

return builder.build();
}
Expand Down
Loading

0 comments on commit ee95b9c

Please sign in to comment.