Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/ci_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI Checking

on:
push:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Checkout submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1

- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8

- name: Testing Building and Checking Style
run: ./gradlew check
env:
PGP_PASS: ZQz7MqGSX5AQb3XQ
11 changes: 5 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'java'
id 'jacoco'
id 'com.google.cloud.tools.jib' version '2.5.0'
// id "checkstyle"
id 'checkstyle'
}

version = "${project_version}" + (isSnapshot() ? '.' + getBuildNumber() : '')
Expand Down Expand Up @@ -87,17 +87,16 @@ jib {
}
}

//checkstyle {
// configFile = file("checkstyle.xml")
// toolVersion = '8.10'
//}
checkstyle {
toolVersion "8.36.2"
}

static String getBuildNumber() {
return System.getenv("GITHUB_RUN_NUMBER") ?: "0"
}

static boolean isSnapshot() {
String ref = System.getenv("GITHUB_REF");
String ref = System.getenv("GITHUB_REF")
if (ref != null && ref.startsWith("refs/tags/v")) {
return false
}
Expand Down
38 changes: 17 additions & 21 deletions checkstyle.xml → config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
default="checkstyle-suppressions.xml" />
<property name="optional" value="true"/>
</module>
<module name="SuppressionCommentFilter"/>

<!-- Checks for whitespace -->
<!-- See http://checkstyle.org/config_whitespace.html -->
Expand Down Expand Up @@ -57,7 +58,6 @@
<property name="allowByTailComment" value="true"/>
<property name="allowNonPrintableEscapes" value="true"/>
</module>
<module name="AvoidStarImport"/>
<module name="OneTopLevelClass"/>
<module name="NoLineWrap">
<property name="tokens" value="PACKAGE_DEF, IMPORT, STATIC_IMPORT"/>
Expand All @@ -83,14 +83,9 @@
<property name="id" value="RightCurlySame"/>
<property name="tokens"
value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE,
LITERAL_DO"/>
</module>
<module name="RightCurly">
<property name="id" value="RightCurlyAlone"/>
<property name="option" value="alone"/>
<property name="tokens"
value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, STATIC_INIT,
CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, STATIC_INIT,
INSTANCE_INIT, ANNOTATION_DEF, ENUM_DEF"/>
<property name="option" value="alone" />
</module>
<module name="SuppressionXpathSingleFilter">
<!-- suppresion is required till https://github.com/checkstyle/checkstyle/issues/7541 -->
Expand Down Expand Up @@ -173,7 +168,7 @@
value="Type name ''{0}'' must match pattern ''{1}''."/>
</module>
<module name="MemberName">
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
<message key="name.invalidPattern"
value="Member name ''{0}'' must match pattern ''{1}''."/>
</module>
Expand Down Expand Up @@ -238,16 +233,17 @@
value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, ANNOTATION_DEF, ANNOTATION_FIELD_DEF,
PARAMETER_DEF, VARIABLE_DEF, METHOD_DEF"/>
</module>
<!--
Waiting on https://github.com/checkstyle/checkstyle/issues/3770
<module name="OverloadMethodsDeclarationOrder"/>
-->
<module name="VariableDeclarationUsageDistance"/>
<module name="CustomImportOrder">
<property name="customImportOrderRules"
value="STANDARD_JAVA_PACKAGE###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE###SAME_PACKAGE(1)###STATIC"/>
<property name="standardPackageRegExp" value="^java\."/>
<property name="specialImportsRegExp" value="^javax\."/>
<property name="thirdPartyPackageRegExp" value="^org\."/>
<property name="sortImportsInGroupAlphabetically" value="true"/>
<property name="separateLineBetweenGroups" value="true"/>
<module name="ImportOrder">
<property name="groups"
value="java,javax,org,*"/>
<property name="separated" value="true"/>
<property name="option" value="top"/>
<property name="sortStaticImportsAlphabetically" value="true"/>
</module>
<module name="MethodParamPad">
<property name="tokens" value="METHOD_DEF"/>
Expand All @@ -271,7 +267,7 @@
<property name="option" value="NL"/>
<property name="tokens"
value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR,
LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR, METHOD_REF "/>
LT, MINUS, MOD, NOT_EQUAL, PLUS, SL, SR, STAR, METHOD_REF "/>
</module>
<module name="AnnotationLocation">
<property name="id" value="AnnotationLocationMostCases"/>
Expand Down Expand Up @@ -300,13 +296,13 @@
<property name="scope" value="public"/>
<property name="allowMissingParamTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/>
<property name="allowedAnnotations" value="Override, Test"/>
<property name="allowedAnnotations" value="Override, Test, BeforeAll"/>
<property name="tokens" value="METHOD_DEF, CTOR_DEF, ANNOTATION_FIELD_DEF"/>
</module>
<module name="MissingJavadocMethod">
<property name="scope" value="public"/>
<property name="minLineCount" value="2"/>
<property name="allowedAnnotations" value="Override, Test"/>
<property name="allowedAnnotations" value="Override, Test, BeforeAll"/>
<property name="tokens" value="METHOD_DEF, CTOR_DEF, ANNOTATION_FIELD_DEF"/>
</module>
<module name="MethodName">
Expand All @@ -318,7 +314,7 @@
<property name="ignoreInlineTags" value="false"/>
</module>
<module name="EmptyCatchBlock">
<property name="exceptionVariableName" value="expected"/>
<property name="exceptionVariableName" value="ignored"/>
</module>
<module name="CommentsIndentation">
<property name="tokens" value="SINGLE_LINE_COMMENT, BLOCK_COMMENT_BEGIN"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class DataAuthorizedProjectContributor extends DataProjectContributor {
public DataAuthorizedProjectContributor (ProjectAuthorsEntity projectAuthor) {

super(projectAuthor);
this.permissions = projectAuthor.getPermissions().stream().map(ProjectAuthorPermissionsEntity::getPermission).collect(Collectors.toList());
this.permissions = projectAuthor.getPermissions().stream().map(ProjectAuthorPermissionsEntity::getPermission)
.collect(Collectors.toList());
}
}
3 changes: 2 additions & 1 deletion src/main/java/com/diluv/api/data/DataBaseProject.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ public DataBaseProject (ProjectsEntity rs) {
this.projectType = new DataBaseProjectType(rs.getProjectType());
this.contributors.add(new DataProjectContributor(rs.getOwner(), "owner"));
if (!rs.getAuthors().isEmpty()) {
this.contributors.addAll(rs.getAuthors().stream().map(DataProjectContributor::new).collect(Collectors.toList()));
this.contributors.addAll(rs.getAuthors().stream().map(DataProjectContributor::new)
.collect(Collectors.toList()));
}
}
}
3 changes: 2 additions & 1 deletion src/main/java/com/diluv/api/data/DataFeatured.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public class DataFeatured {
@Expose
private final long contributorCount;

public DataFeatured (List<DataGame> games, List<DataBaseProject> projects, long projectCount, long contributorCount) {
public DataFeatured (List<DataGame> games, List<DataBaseProject> projects, long projectCount,
long contributorCount) {

this.games = games;
this.projects = projects;
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/com/diluv/api/data/DataProjectFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ public DataProjectFile (ProjectFilesEntity rs, String gameSlug, String projectTy

this.id = rs.getId();
this.name = rs.getName();
this.downloadURL = Constants.getDiluvCDN(gameSlug, projectTypeSlug, rs.getProject().getId(), rs.getId(), rs.getName());
this.downloadURL =
Constants.getDiluvCDN(gameSlug, projectTypeSlug, rs.getProject().getId(), rs.getId(), rs.getName());
this.size = rs.getSize();
this.changelog = rs.getChangelog();
this.sha512 = rs.getSha512();
Expand All @@ -130,8 +131,11 @@ public DataProjectFile (ProjectFilesEntity rs, String gameSlug, String projectTy
this.uploaderUserId = rs.getUser().getId();
this.uploaderUsername = rs.getUser().getUsername();
this.uploaderDisplayName = rs.getUser().getDisplayName();
this.dependencies = rs.getDependencies().stream().map(a -> a.getDependencyProject().getId()).collect(Collectors.toList());
this.gameVersions = rs.getGameVersions().stream().map(a -> new DataGameVersion(a.getGameVersion())).collect(Collectors.toList());
this.dependencies =
rs.getDependencies().stream().map(a -> a.getDependencyProject().getId()).collect(Collectors.toList());
this.gameVersions =
rs.getGameVersions().stream().map(a -> new DataGameVersion(a.getGameVersion()))
.collect(Collectors.toList());
this.gameSlug = gameSlug;
this.projectTypeSlug = projectTypeSlug;
this.projectSlug = projectSlug;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public class DataProjectFileAvailable extends DataProjectFile {
@Expose
private final long updatedAt;

public DataProjectFileAvailable (ProjectFilesEntity rs, String projectSlug, String projectTypeSlug, String gameSlug) {
public DataProjectFileAvailable (ProjectFilesEntity rs, String projectSlug, String projectTypeSlug,
String gameSlug) {

super(rs, projectSlug, projectTypeSlug, gameSlug);
this.updatedAt = rs.getUpdatedAt().getTime();
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/diluv/api/data/DataProjectFileInQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public class DataProjectFileInQueue extends DataProjectFile {
@Expose
private final long lastStatusChanged;

public DataProjectFileInQueue (ProjectFilesEntity record, String gameSlug, String projectTypeSlug, String projectSlug) {
public DataProjectFileInQueue (ProjectFilesEntity record, String gameSlug, String projectTypeSlug,
String projectSlug) {

super(record, gameSlug, projectTypeSlug, projectSlug);
this.status = record.getProcessingStatus().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public class DataSiteGameProjects {
@Expose
private final List<DataSort> sorts;

public DataSiteGameProjects (List<DataBaseProject> projects, List<DataBaseProjectType> types, DataProjectType currentType, List<DataSort> sorts) {
public DataSiteGameProjects (List<DataBaseProject> projects, List<DataBaseProjectType> types,
DataProjectType currentType, List<DataSort> sorts) {

this.projects = projects;
this.types = types;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/diluv/api/data/site/DataSiteIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public class DataSiteIndex {
@Expose
private final long projectTypeCount;

public DataSiteIndex (List<DataSiteGame> featuredGames, long projectCount, long contributorCount, long gameCount, long projectTypeCount) {
public DataSiteIndex (List<DataSiteGame> featuredGames, long projectCount, long contributorCount, long gameCount,
long projectTypeCount) {

this.featuredGames = featuredGames;
this.projectCount = projectCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ public DataSiteProjectFileDisplay (ProjectFilesEntity rs, List<DataGameVersion>
this.gameSlug = rs.getProject().getGame().getSlug();
this.projectTypeSlug = rs.getProject().getProjectType().getSlug();
this.projectSlug = rs.getProject().getSlug();
this.downloadURL = Constants.getDiluvCDN(this.gameSlug, this.projectTypeSlug, rs.getProject().getId(), rs.getId(), rs.getName());
this.downloadURL = Constants.getDiluvCDN(
this.gameSlug, this.projectTypeSlug, rs.getProject().getId(), rs.getId(), rs.getName());
this.size = rs.getSize();
this.sha512 = rs.getSha512();
this.downloads = rs.getDownloads();
Expand Down
15 changes: 10 additions & 5 deletions src/main/java/com/diluv/api/graphql/Mutation.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

public class Mutation implements GraphQLMutationResolver {

public ProjectType addProjectType (String gameSlug, String projectTypeSlug, String projectTypeName, boolean isDefault, Long maxFileSize) {
public ProjectType addProjectType (String gameSlug, String projectTypeSlug, String projectTypeName,
boolean isDefault, Long maxFileSize) {

return Confluencia.getTransaction(session -> {
GamesEntity game = Confluencia.GAME.findOneBySlug(session, gameSlug);
Expand Down Expand Up @@ -47,10 +48,12 @@ public ProjectType addProjectType (String gameSlug, String projectTypeSlug, Stri
});
}

public ProjectType updateProjectType (String gameSlug, String projectTypeSlug, String projectTypeName, Boolean isDefault, Long maxFileSize) {
public ProjectType updateProjectType (String gameSlug, String projectTypeSlug, String projectTypeName,
Boolean isDefault, Long maxFileSize) {

return Confluencia.getTransaction(session -> {
ProjectTypesEntity projectType = Confluencia.PROJECT.findOneProjectTypeByGameSlugAndProjectTypeSlug(session, gameSlug, projectTypeSlug);
ProjectTypesEntity projectType =
Confluencia.PROJECT.findOneProjectTypeByGameSlugAndProjectTypeSlug(session, gameSlug, projectTypeSlug);
if (projectType == null) {
throw new GraphQLException("Project Type doesn't exists");
}
Expand Down Expand Up @@ -109,7 +112,8 @@ public Project reviewed (long projectId, boolean requestChange, String reason, D
public ProjectType addTag (String gameSlug, String projectTypeSlug, String tagSlug, String tagName) {

return Confluencia.getTransaction(session -> {
ProjectTypesEntity projectType = Confluencia.PROJECT.findOneProjectTypeByGameSlugAndProjectTypeSlug(session, gameSlug, projectTypeSlug);
ProjectTypesEntity projectType =
Confluencia.PROJECT.findOneProjectTypeByGameSlugAndProjectTypeSlug(session, gameSlug, projectTypeSlug);
if (projectType == null) {
throw new GraphQLException("Project Type doesn't exists");
}
Expand All @@ -126,7 +130,8 @@ public ProjectType addLoader (String gameSlug, String projectTypeSlug, String lo

return Confluencia.getTransaction(session -> {

ProjectTypesEntity projectType = Confluencia.PROJECT.findOneProjectTypeByGameSlugAndProjectTypeSlug(session, gameSlug, projectTypeSlug);
ProjectTypesEntity projectType =
Confluencia.PROJECT.findOneProjectTypeByGameSlugAndProjectTypeSlug(session, gameSlug, projectTypeSlug);
if (projectType == null) {
throw new GraphQLException("Project Type doesn't exists");
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/diluv/api/graphql/ProjectResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public List<Author> authors (Project project) {

List<Author> authors = new ArrayList<>();
authors.add(new Author(new User(project.getEntity().getOwner()), "owner"));
authors.addAll(project.getEntity().getAuthors().stream().map(a -> new Author(new User(a.getUser()), a.getRole())).collect(Collectors.toList()));
authors.addAll(project.getEntity().getAuthors().stream().map(a ->
new Author(new User(a.getUser()), a.getRole())).collect(Collectors.toList()));
return authors;
}

Expand Down
33 changes: 15 additions & 18 deletions src/main/java/com/diluv/api/graphql/Query.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,21 @@ public class Query implements GraphQLQueryResolver {

public List<Game> games (long page, int limit, String sort) {

return Confluencia.getTransaction(session -> {
return Confluencia.GAME.findAll(session, page, limit, getSortOrDefault(sort, ProjectSort.LIST, ProjectSort.NEW), "").stream().map(Game::new).collect(Collectors.toList());
});
return Confluencia.getTransaction(session ->
Confluencia.GAME.findAll(session, page, limit, getSortOrDefault(sort, ProjectSort.LIST, ProjectSort.NEW),
"").stream().map(Game::new).collect(Collectors.toList()));
}

public Game game (String gameSlug) {

return Confluencia.getTransaction(session -> {
return new Game(Confluencia.GAME.findOneBySlug(session, gameSlug));
});
return Confluencia.getTransaction(session -> new Game(Confluencia.GAME.findOneBySlug(session, gameSlug)));
}

public ProjectType projectType (String gameSlug, String projectTypeSlug) {

return Confluencia.getTransaction(session -> {
return new ProjectType(Confluencia.PROJECT.findOneProjectTypeByGameSlugAndProjectTypeSlug(session, gameSlug, projectTypeSlug));
});
return Confluencia.getTransaction(session ->
new ProjectType(Confluencia.PROJECT.findOneProjectTypeByGameSlugAndProjectTypeSlug(
session, gameSlug, projectTypeSlug)));
}

public Project project (String gameSlug, String projectTypeSlug, String projectSlug) {
Expand All @@ -48,28 +46,27 @@ public Project projectById (long projectId) {

public List<ProjectType> projectTypes (String gameSlug) {

return Confluencia.getTransaction(session -> {
return Confluencia.GAME.findAllProjectTypesByGameSlug(session, gameSlug).stream().map(ProjectType::new).collect(Collectors.toList());
});
return Confluencia.getTransaction(session ->
Confluencia.GAME.findAllProjectTypesByGameSlug(session, gameSlug).stream().map(ProjectType::new)
.collect(Collectors.toList()));
}

public List<Project> projects (String gameSlug, String projectTypeSlug, Long page, Integer limit, String sort) {

long p = PaginationQuery.getPage(page);
int l = PaginationQuery.getLimit(limit);
Sort s = getSortOrDefault(sort, ProjectSort.LIST, ProjectSort.NEW);
return Confluencia.getTransaction(session -> {
return Confluencia.PROJECT.findAllByGameAndProjectType(session, gameSlug, projectTypeSlug, "", p, l, s).stream().map(Project::new).collect(Collectors.toList());
});
return Confluencia.getTransaction(session ->
Confluencia.PROJECT.findAllByGameAndProjectType(session, gameSlug, projectTypeSlug, "", p, l, s).stream()
.map(Project::new).collect(Collectors.toList()));
}

public List<Project> projectReviews (Long page, Integer limit) {

long p = PaginationQuery.getPage(page);
int l = PaginationQuery.getLimit(limit);
return Confluencia.getTransaction(session -> {
return Confluencia.PROJECT.findAllByReview(session, p, l).stream().map(Project::new).collect(Collectors.toList());
});
return Confluencia.getTransaction(session ->
Confluencia.PROJECT.findAllByReview(session, p, l).stream().map(Project::new).collect(Collectors.toList()));
}

public Sort getSortOrDefault (String sort, List<Sort> sortList, Sort defaultSort) {
Expand Down
Loading