Sonar Fixes (5) (#2211)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-01-21 11:20:50 +02:00
committed by GitHub
parent 33a6250646
commit 567e8b38f1
59 changed files with 240 additions and 276 deletions

View File

@@ -26,15 +26,13 @@ import org.springframework.data.repository.core.support.RepositoryFactorySupport
* @param <S>
* @param <ID>
*/
public class CustomBaseRepositoryFactoryBean<T extends Repository<S, ID>, S, ID>
extends JpaRepositoryFactoryBean<T, S, ID> {
public class CustomBaseRepositoryFactoryBean<T extends Repository<S, ID>, S, ID> extends JpaRepositoryFactoryBean<T, S, ID> {
@Autowired
BaseRepositoryTypeProvider baseRepoProvider;
/**
* Creates a new {@link JpaRepositoryFactoryBean} for the given repository
* interface.
* Creates a new {@link JpaRepositoryFactoryBean} for the given repository interface.
*
* @param repositoryInterface must not be {@literal null}.
*/

View File

@@ -23,7 +23,7 @@ import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.User;
import org.springframework.util.StringUtils;
import org.springframework.util.ObjectUtils;
/**
* Default implementation of {@link RolloutApprovalStrategy}. Decides whether
@@ -93,7 +93,7 @@ public class DefaultRolloutApprovalStrategy implements RolloutApprovalStrategy {
if (RolloutStatus.CREATING == rollout.getStatus()) {
final String actor = rollout.getLastModifiedBy() != null ? rollout.getLastModifiedBy()
: rollout.getCreatedBy();
if (!StringUtils.isEmpty(actor)) {
if (!ObjectUtils.isEmpty(actor)) {
return systemSecurityContext.runAsSystem(
() -> userAuthoritiesResolver.getUserAuthorities(rollout.getTenant(), actor));
}

View File

@@ -16,7 +16,6 @@ import jakarta.persistence.Column;
import jakarta.persistence.ConstraintMode;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.ForeignKey;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;

View File

@@ -124,8 +124,8 @@ public interface BaseEntityRepository<T extends AbstractJpaTenantAwareBaseEntity
default <T extends AbstractJpaTenantAwareBaseEntity> Specification<T> byIdsSpec(final Iterable<Long> ids) {
final Collection<Long> collection;
if (ids instanceof Collection<Long>) {
collection = (Collection<Long>) ids;
if (ids instanceof Collection<Long> idCollection) {
collection = idCollection;
} else {
collection = new LinkedList<>();
ids.forEach(collection::add);

View File

@@ -326,8 +326,7 @@ public class BaseEntityRepositoryACM<T extends AbstractJpaTenantAwareBaseEntity>
try {
// TODO - cache mapping so to speed things
final Method delegateMethod =
BaseEntityRepositoryACM.class.getDeclaredMethod(
method.getName(), method.getParameterTypes());
BaseEntityRepositoryACM.class.getDeclaredMethod(method.getName(), method.getParameterTypes());
return delegateMethod.invoke(repositoryACM, args);
} catch (final NoSuchMethodException e) {
// call to repository itself
@@ -369,7 +368,7 @@ public class BaseEntityRepositoryACM<T extends AbstractJpaTenantAwareBaseEntity>
}
@SuppressWarnings({ "rawtypes", "unchecked" })
private static <T extends Long> Set<Long> toSetDistinct(final Iterable<T> i) {
private static Set<Long> toSetDistinct(final Iterable<? extends Long> i) {
final Set<Long> set = new HashSet<>();
i.forEach(set::add);
return set;