Skip to content

Commit

Permalink
Implement CheckStyle + Code Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-w1lde committed Oct 13, 2024
1 parent 6a01962 commit e50db18
Show file tree
Hide file tree
Showing 30 changed files with 1,626 additions and 922 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/checkstyle-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This workflow performs a static analysis of your Java source code using
# Detekt.
#
# Scans are triggered:
# 1. On every push to default and protected branches
# 2. On every Pull Request targeting the default branch
# 3. On a weekly schedule
# 4. Manually, on demand, via the "workflow_dispatch" event
#
name: CheckStyle

on:
# Triggers the workflow on push or pull request events but only for default and protected branches
push:
branches: [ master ]
paths:
- ".github/workflows/checkstyle-analysis.yml"
- "src/**"
- "pom.xml"
pull_request:
branches: [ master ]
paths:
- ".github/workflows/checkstyle-analysis.yml"
- "src/**"
- "pom.xml"

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
detekt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 23
uses: actions/setup-java@v3
with:
java-version: "23"
distribution: "adopt"
cache: mvnw
- name: Grant execute permission for mvnw
run: chmod +x mvnw
- name: Check
run: ./mvnw checkstyle:check
384 changes: 384 additions & 0 deletions checkstyle.xml

Large diffs are not rendered by default.

46 changes: 45 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,59 @@
<artifactId>aerogear-otp-java</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.3.1-jre</version> <!-- Use a stable and compatible version -->
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version> <!-- Use the appropriate version for your setup -->
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.34</version> <!-- Same version as in dependencies -->
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.5.0</version> <!-- Use the latest stable version -->
<configuration>
<configLocation>checkstyle.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
</configuration>
<executions>
<execution>
<phase>validate</phase> <!-- Checkstyle will run in the validate phase -->
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>10.18.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

</project>
8 changes: 3 additions & 5 deletions src/main/java/net/furizon/backend/BackendApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

@SpringBootApplication
public class BackendApplication {

public static void main(String[] args) {
SpringApplication.run(BackendApplication.class, args);
}

public static void main(String[] args) {
SpringApplication.run(BackendApplication.class, args);
}
}
75 changes: 43 additions & 32 deletions src/main/java/net/furizon/backend/db/entities/pretix/Event.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package net.furizon.backend.db.entities.pretix;

import jakarta.persistence.*;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import jakarta.persistence.Transient;
import lombok.Getter;
import lombok.Setter;

Expand All @@ -9,36 +14,42 @@

@Entity
@Table(name = "events")
@Getter
public final class Event {
@Id
@Getter
private String slug;

@Getter
private String publicUrl;

@Getter @Transient //TODO transform to string
private Map<String, String> eventName; //map lang -> name

@Getter
private String dateFrom, dateEnd;

@Getter @Setter
private boolean isCurrentEvent;

@Getter
@OneToMany(mappedBy = "orderEvent", fetch = FetchType.LAZY)
private Set<Order> orders;

public Event(String organizer, String event, String publicUrl, Map<String, String> eventName, String dateFrom, String dateEnd){
slug = getSlug(organizer, event);
this.publicUrl = publicUrl + "/" + slug;
this.eventName = eventName;
this.dateFrom = dateFrom;
this.dateEnd = dateEnd;
}

public static String getSlug(String organizer, String event){
return organizer + "/" + event;
}
@Id
private String slug;

private String publicUrl;

@Transient //TODO transform to string
private Map<String, String> eventName; //map lang -> name

private String dateFrom;

private String dateEnd;

@Setter
private boolean isCurrentEvent;

@OneToMany(mappedBy = "orderEvent", fetch = FetchType.LAZY)
private Set<Order> orders;

public Event(
String organizer,
String event,
String publicUrl,
Map<String, String> eventName,
String dateFrom,
String dateEnd
) {
slug = getSlug(organizer, event);
this.publicUrl = publicUrl + "/" + slug;
this.eventName = eventName;
this.dateFrom = dateFrom;
this.dateEnd = dateEnd;
}

public static String getSlug(String organizer, String event) {
return organizer + "/" + event;
}
}
Loading

0 comments on commit e50db18

Please sign in to comment.