Skip to content

Commit

Permalink
ci: decomission of PMD
Browse files Browse the repository at this point in the history
The following issue won't be fixed:
Closes #195
Closes #261
Closes #1018
Closes #1250
Closes #1646

Part of #1669
  • Loading branch information
php-coder committed Feb 25, 2024
1 parent 0248534 commit cb0d680
Show file tree
Hide file tree
Showing 91 changed files with 23 additions and 528 deletions.
25 changes: 0 additions & 25 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,6 @@ defaults:

jobs:

run-pmd:
name: Run PMD
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on
runs-on: ubuntu-20.04
steps:
- name: Clone source code
uses: actions/[email protected] # https://github.com/actions/checkout
with:
# Whether to configure the token or SSH key with the local git config. Default: true
persist-credentials: false
- name: Install JDK
uses: actions/[email protected] # https://github.com/actions/setup-java
with:
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
- name: Restore existing cache
uses: actions/[email protected] # https://github.com/actions/cache
with:
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#input-parameters-for-the-cache-action
key: maven-repository-${{ hashFiles('pom.xml') }}
path: ~/.m2/repository
restore-keys: maven-repository-
- name: Run PMD
run: ./src/main/scripts/execute-command.sh pmd

check-license:
name: Check license in file headers
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on
Expand Down
15 changes: 0 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,6 @@

<native2ascii.plugin.version>2.0.1</native2ascii.plugin.version>
<nodejs.version>v10.16.0</nodejs.version>
<pmd.plugin.version>3.12.0</pmd.plugin.version>

<!-- Redefine default value from spring-boot-dependencies -->
<postgresql.version>9.4.1212.jre7</postgresql.version>
Expand Down Expand Up @@ -912,20 +911,6 @@
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${pmd.plugin.version}</version>
<configuration>
<linkXRef>false</linkXRef>
<verbose>true</verbose>
<targetJdk>${java.version}</targetJdk>
<rulesets>
<ruleset>${basedir}/src/main/config/pmd.xml</ruleset>
</rulesets>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
Expand Down
323 changes: 0 additions & 323 deletions src/main/config/pmd.xml

This file was deleted.

3 changes: 0 additions & 3 deletions src/main/java/ru/mystamps/web/common/JdbcUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ private JdbcUtils() {
}

// @see https://stackoverflow.com/q/2920364/checking-for-a-null-int-value-from-a-java-resultset
@SuppressWarnings("PMD.PrematureDeclaration")
public static Integer getInteger(ResultSet resultSet, String fieldName) throws SQLException {
int value = resultSet.getInt(fieldName);
if (resultSet.wasNull()) {
Expand All @@ -38,7 +37,6 @@ public static Integer getInteger(ResultSet resultSet, String fieldName) throws S
return Integer.valueOf(value);
}

@SuppressWarnings("PMD.PrematureDeclaration")
public static Boolean getBoolean(ResultSet resultSet, String fieldName) throws SQLException {
boolean value = resultSet.getBoolean(fieldName);
if (resultSet.wasNull()) {
Expand All @@ -51,7 +49,6 @@ public static Boolean getBoolean(ResultSet resultSet, String fieldName) throws S
/**
* @author Sergey Chechenev
*/
@SuppressWarnings("PMD.PrematureDeclaration")
public static Currency getCurrency(ResultSet resultSet, String fieldName) throws SQLException {
String value = resultSet.getString(fieldName);
if (resultSet.wasNull()) {
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/ru/mystamps/web/common/Pager.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import java.util.Collections;
import java.util.List;

// yes, I know that it's too complex :-(
@SuppressWarnings("PMD.ModifiedCyclomaticComplexity")
@ToString
public class Pager {
// be very careful when you're changing this value
Expand All @@ -41,15 +39,12 @@ public class Pager {
private static final int FIRST_PAGE = 1;

// this field is shown in toString() and useful when debugging unit tests
@SuppressWarnings("PMD.SingularField")
private final int totalRecords;

// this field is shown in toString() and useful when debugging unit tests
@SuppressWarnings("PMD.SingularField")
private final int totalPages;

// this field is shown in toString() and useful when debugging unit tests
@SuppressWarnings({ "PMD.SingularField", "PMD.UnusedPrivateField" })
private final int recordsPerPage;

// this field is using in the view (hence its getter)
Expand Down Expand Up @@ -106,8 +101,6 @@ private static Integer findNext(int currentPage, int totalPages) {
return Integer.valueOf(currentPage + 1);
}

// I hope that we'll fix these one day
@SuppressWarnings("PMD.NPathComplexity")
private static List<Integer> createItems(
int totalRecords,
int recordsPerPage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
package ru.mystamps.web.feature.account;

@SuppressWarnings("PMD.CommentDefaultAccessModifier")
final class AccountDb {

static final class UsersActivation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
*
* @author Slava Semushin
*/
@SuppressWarnings("PMD.CommentDefaultAccessModifier")
public final class AccountUrl {

public static final String REGISTRATION_PAGE = "/account/register";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@
import ru.mystamps.web.feature.account.AccountDb.User;
import ru.mystamps.web.feature.account.AccountDb.UsersActivation;

@SuppressWarnings("PMD.CommentDefaultAccessModifier")
public final class AccountValidation {

public static final int LOGIN_MIN_LENGTH = 2;
public static final int LOGIN_MAX_LENGTH = User.LOGIN_LENGTH;
static final String LOGIN_REGEXP = "[-_\\.a-zA-Z0-9]+";
@SuppressWarnings("PMD.LongVariable")
static final String LOGIN_NO_REPEATING_CHARS_REGEXP = "(?!.+[-_.]{2,}).+";

static final int NAME_MAX_LENGTH = User.NAME_LENGTH;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.List;
import java.util.Map;

@SuppressWarnings("PMD.AvoidDuplicateLiterals")
public class JdbcUsersActivationDao implements UsersActivationDao {

private final NamedParameterJdbcTemplate jdbcTemplate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
/**
* Implementation that delegates calls to a category service.
*/
@SuppressWarnings("PMD.TooManyMethods")
public class ApiCategoryService implements CategoryService {

private static final Logger LOG = LoggerFactory.getLogger(ApiCategoryService.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.util.List;
import java.util.Map;

@SuppressWarnings("PMD.TooManyMethods")
public interface CategoryDao {
Integer add(AddCategoryDbDto category);
long countAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
package ru.mystamps.web.feature.category;

@SuppressWarnings("PMD.CommentDefaultAccessModifier")
final class CategoryDb {

static final class Category {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.util.List;
import java.util.Map;

@SuppressWarnings("PMD.TooManyMethods")
public interface CategoryService {
String add(AddCategoryDto dto, Integer userId);
List<Integer> findIdsByNames(List<String> names);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import java.util.Map;
import java.util.stream.Collectors;

@SuppressWarnings("PMD.TooManyMethods")
@RequiredArgsConstructor
public class CategoryServiceImpl implements CategoryService {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
*
* @author Slava Semushin
*/
@SuppressWarnings("PMD.CommentDefaultAccessModifier")
public final class CategoryUrl {

public static final String SUGGEST_SERIES_CATEGORY = "/suggest/series_category";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@

import ru.mystamps.web.feature.category.CategoryDb.Category;

@SuppressWarnings("PMD.CommentDefaultAccessModifier")
public final class CategoryValidation {

public static final int NAME_MIN_LENGTH = 3;
public static final int NAME_MAX_LENGTH = Category.NAME_LENGTH;
public static final String NAME_EN_REGEXP = "[- a-zA-Z]+";
public static final String NAME_RU_REGEXP = "[- а-яёА-ЯЁ]+";
static final String NAME_NO_HYPHEN_REGEXP = "[ \\p{L}]([- \\p{L}]+[ \\p{L}])*";
@SuppressWarnings("PMD.LongVariable")
static final String NAME_NO_REPEATING_HYPHENS_REGEXP = "(?!.+[-]{2,}).+";

private CategoryValidation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import java.util.List;
import java.util.Map;

@SuppressWarnings({ "PMD.AvoidDuplicateLiterals", "PMD.TooManyMethods", "PMD.TooManyFields" })
public class JdbcCategoryDao implements CategoryDao {

private static final ResultSetExtractor<Map<String, Integer>> NAME_COUNTER_EXTRACTOR =
Expand All @@ -59,9 +58,7 @@ public class JdbcCategoryDao implements CategoryDao {
private final String findCategoriesNamesWithSlugSql;
private final String findAllForSitemapSql;
private final String findLinkEntityBySlugSql;
@SuppressWarnings("PMD.LongVariable")
private final String findCategoriesWithParentNamesSql;
@SuppressWarnings("PMD.LongVariable")
private final String findFromLastCreatedSeriesByUserSql;

public JdbcCategoryDao(Environment env, NamedParameterJdbcTemplate jdbcTemplate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
* @see CategoryServiceImpl
*/
@RequiredArgsConstructor
@SuppressWarnings("PMD.TooManyMethods")
public class TogglzWithFallbackCategoryService implements CategoryService {

private static final Logger LOG =
Expand Down Expand Up @@ -185,7 +184,7 @@ private static <T> T executeOneOf(Callable<T> firstImpl, Callable<T> defaultImpl
} catch (UnsupportedOperationException ignored) {
// the method isn't yet implemented, fallback to the default implementation

} catch (RuntimeException e) { // NOPMD: AvoidCatchingGenericException; catch-all
} catch (RuntimeException e) {
LOG.warn(
"Failed to call a category service. Fallback to default implementation",
e
Expand All @@ -194,8 +193,8 @@ private static <T> T executeOneOf(Callable<T> firstImpl, Callable<T> defaultImpl
}
return defaultImpl.call();

} catch (Exception ex) { // NOPMD: AvoidCatchingGenericException; try to catch-all
throw new RuntimeException(ex); // NOPMD: AvoidThrowingRawExceptionTypes
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public void initialize(UniqueCategoryName annotation) {
}

@Override
@SuppressWarnings("PMD.SimplifyBooleanReturns")
public boolean isValid(String value, ConstraintValidatorContext ctx) {

if (value == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.List;
import java.util.Map;

@SuppressWarnings("PMD.TooManyMethods")
public interface CollectionDao {
List<LinkEntityDto> findLastCreated(int quantity);
List<SeriesInCollectionDto> findSeriesByCollectionId(Integer collectionId, String lang);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.List;
import java.util.Map;

@SuppressWarnings("PMD.TooManyMethods")
public interface CollectionService {
void createCollection(Integer ownerId, String ownerLogin);
void addToCollection(Integer userId, AddToCollectionDto dto);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@
import java.util.Map;

@RequiredArgsConstructor
@SuppressWarnings({
"PMD.TooManyMethods",
// complains on "Series id must be non null"
"PMD.AvoidDuplicateLiterals"
})
public class CollectionServiceImpl implements CollectionService {

private final Logger log;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import java.util.List;
import java.util.Map;

@SuppressWarnings({ "PMD.AvoidDuplicateLiterals", "PMD.TooManyMethods", "PMD.TooManyFields" })
public class JdbcCollectionDao implements CollectionDao {
private static final Logger LOG = LoggerFactory.getLogger(JdbcCollectionDao.class);

Expand Down Expand Up @@ -269,7 +268,6 @@ public Integer addSeriesToUserCollection(AddToCollectionDbDto dto) {
return holder.getKey().intValue();
}

@SuppressWarnings("PMD.AvoidLiteralsInIfCondition")
@Override
public void removeSeriesFromUserCollection(Integer userId, Integer seriesInstanceId) {
Map<String, Object> params = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
/**
* Implementation that delegates calls to a country service.
*/
@SuppressWarnings("PMD.TooManyMethods")
public class ApiCountryService implements CountryService {

private static final Logger LOG = LoggerFactory.getLogger(ApiCountryService.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.List;
import java.util.Map;

@SuppressWarnings("PMD.TooManyMethods")
public interface CountryDao {
Integer add(AddCountryDbDto country);
long countAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
package ru.mystamps.web.feature.country;

@SuppressWarnings("PMD.CommentDefaultAccessModifier")
final class CountryDb {

static final class Country {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.List;
import java.util.Map;

@SuppressWarnings("PMD.TooManyMethods")
public interface CountryService {
String add(AddCountryDto dto, Integer userId);
List<Integer> findIdsByNames(List<String> names);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import java.util.stream.Collectors;

@RequiredArgsConstructor
@SuppressWarnings("PMD.TooManyMethods")
public class CountryServiceImpl implements CountryService {

private final Logger log;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
*
* @author Slava Semushin
*/
@SuppressWarnings("PMD.CommentDefaultAccessModifier")
public final class CountryUrl {

public static final String SUGGEST_SERIES_COUNTRY = "/suggest/series_country";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@

import ru.mystamps.web.feature.country.CountryDb.Country;

@SuppressWarnings("PMD.CommentDefaultAccessModifier")
public final class CountryValidation {

public static final int NAME_MIN_LENGTH = 3;
public static final int NAME_MAX_LENGTH = Country.NAME_LENGTH;
public static final String NAME_EN_REGEXP = "[- a-zA-Z]+";
public static final String NAME_RU_REGEXP = "[- а-яёА-ЯЁ]+";
static final String NAME_NO_HYPHEN_REGEXP = "[ \\p{L}]([- \\p{L}]+[ \\p{L}])*";
@SuppressWarnings("PMD.LongVariable")
static final String NAME_NO_REPEATING_HYPHENS_REGEXP = "(?!.+[-]{2,}).+";

private CountryValidation() {
Expand Down
Loading

0 comments on commit cb0d680

Please sign in to comment.