From 21439c3e0b7c7396ad859149bcbf2197ac6334e1 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 8 Oct 2020 16:46:05 +0300 Subject: Apply some IDEA suggestions --- .../com/github/scribejava/apis/AppleClientSecretGenerator.java | 3 --- src/main/java/com/juick/KeystoreManager.java | 2 +- src/main/java/com/juick/SignatureManager.java | 9 +++------ src/main/java/com/juick/model/User.java | 2 +- src/main/java/com/juick/service/ImagesServiceImpl.java | 4 ++-- src/main/java/com/juick/service/UserServiceImpl.java | 5 ++--- .../java/com/juick/service/activities/UndoAnnounceEvent.java | 4 ++-- src/main/java/com/juick/service/activities/UndoFollowEvent.java | 4 ++-- src/main/java/com/juick/service/component/SystemEvent.java | 2 +- src/main/java/com/juick/util/ImageUtils.java | 4 ++-- src/main/java/com/juick/www/api/Post.java | 2 +- src/main/java/com/juick/www/api/Service.java | 2 +- 12 files changed, 18 insertions(+), 25 deletions(-) (limited to 'src/main') diff --git a/src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java b/src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java index 67d21a15..10ac4c5a 100644 --- a/src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java +++ b/src/main/java/com/github/scribejava/apis/AppleClientSecretGenerator.java @@ -20,10 +20,7 @@ package com.github.scribejava.apis; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.SignatureAlgorithm; -import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; import java.security.Key; import java.security.KeyFactory; import java.security.NoSuchAlgorithmException; diff --git a/src/main/java/com/juick/KeystoreManager.java b/src/main/java/com/juick/KeystoreManager.java index 50576255..ce7d4a3b 100644 --- a/src/main/java/com/juick/KeystoreManager.java +++ b/src/main/java/com/juick/KeystoreManager.java @@ -35,7 +35,7 @@ import java.util.Arrays; public class KeystoreManager { private static final Logger logger = LoggerFactory.getLogger("ActivityPub"); - private String keystorePassword; + private final String keystorePassword; private KeyStore ks; diff --git a/src/main/java/com/juick/SignatureManager.java b/src/main/java/com/juick/SignatureManager.java index 3575100d..fc92f39a 100644 --- a/src/main/java/com/juick/SignatureManager.java +++ b/src/main/java/com/juick/SignatureManager.java @@ -18,14 +18,14 @@ package com.juick; import com.fasterxml.jackson.databind.ObjectMapper; -import com.juick.model.User; import com.juick.model.AnonymousUser; +import com.juick.model.User; +import com.juick.service.UserService; +import com.juick.util.DateFormattersHolder; import com.juick.www.api.activity.model.Context; import com.juick.www.api.activity.model.objects.Person; import com.juick.www.api.webfinger.model.Account; import com.juick.www.api.webfinger.model.Link; -import com.juick.service.UserService; -import com.juick.util.DateFormattersHolder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpEntity; @@ -34,10 +34,8 @@ import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.web.client.RestTemplate; import org.springframework.web.util.UriComponentsBuilder; -import org.tomitribe.auth.signatures.Algorithm; import org.tomitribe.auth.signatures.Signature; import org.tomitribe.auth.signatures.Signer; -import org.tomitribe.auth.signatures.SigningAlgorithm; import org.tomitribe.auth.signatures.Verifier; import rocks.xmpp.addr.Jid; @@ -48,7 +46,6 @@ import java.security.Key; import java.security.NoSuchAlgorithmException; import java.security.SignatureException; import java.time.Instant; -import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Optional; diff --git a/src/main/java/com/juick/model/User.java b/src/main/java/com/juick/model/User.java index 7a84b115..b43257ed 100644 --- a/src/main/java/com/juick/model/User.java +++ b/src/main/java/com/juick/model/User.java @@ -57,7 +57,7 @@ public class User implements Serializable { private String country; private String url; private String description; - private List tagStats; + private final List tagStats; public User() { tokens = new ArrayList<>(); diff --git a/src/main/java/com/juick/service/ImagesServiceImpl.java b/src/main/java/com/juick/service/ImagesServiceImpl.java index 4bdcd7d6..72d5b97c 100644 --- a/src/main/java/com/juick/service/ImagesServiceImpl.java +++ b/src/main/java/com/juick/service/ImagesServiceImpl.java @@ -28,8 +28,8 @@ import java.io.IOException; import java.nio.file.Paths; public class ImagesServiceImpl implements ImagesService { - private ImageUtils imageUtils; - private String imgDir; + private final ImageUtils imageUtils; + private final String imgDir; public ImagesServiceImpl(String imgDir, String tmpDir) { this.imgDir = imgDir; diff --git a/src/main/java/com/juick/service/UserServiceImpl.java b/src/main/java/com/juick/service/UserServiceImpl.java index c5c49a4f..778872e9 100644 --- a/src/main/java/com/juick/service/UserServiceImpl.java +++ b/src/main/java/com/juick/service/UserServiceImpl.java @@ -17,10 +17,10 @@ package com.juick.service; -import com.juick.model.Message; -import com.juick.model.User; import com.juick.model.AnonymousUser; import com.juick.model.AuthResponse; +import com.juick.model.Message; +import com.juick.model.User; import com.juick.util.UsernameTakenException; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.RandomStringUtils; @@ -41,7 +41,6 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.sql.Timestamp; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; diff --git a/src/main/java/com/juick/service/activities/UndoAnnounceEvent.java b/src/main/java/com/juick/service/activities/UndoAnnounceEvent.java index 6528f259..683e7f78 100644 --- a/src/main/java/com/juick/service/activities/UndoAnnounceEvent.java +++ b/src/main/java/com/juick/service/activities/UndoAnnounceEvent.java @@ -20,8 +20,8 @@ package com.juick.service.activities; import org.springframework.context.ApplicationEvent; public class UndoAnnounceEvent extends ApplicationEvent { - private String actorUri; - private String messageUri; + private final String actorUri; + private final String messageUri; public UndoAnnounceEvent(Object source, String actor, String messageUri) { super(source); diff --git a/src/main/java/com/juick/service/activities/UndoFollowEvent.java b/src/main/java/com/juick/service/activities/UndoFollowEvent.java index a71de980..2f5201a9 100644 --- a/src/main/java/com/juick/service/activities/UndoFollowEvent.java +++ b/src/main/java/com/juick/service/activities/UndoFollowEvent.java @@ -20,8 +20,8 @@ package com.juick.service.activities; import org.springframework.context.ApplicationEvent; public class UndoFollowEvent extends ApplicationEvent { - private String actor; - private String object; + private final String actor; + private final String object; /** * Create a new ApplicationEvent. * diff --git a/src/main/java/com/juick/service/component/SystemEvent.java b/src/main/java/com/juick/service/component/SystemEvent.java index 66fd84ca..749f6af8 100644 --- a/src/main/java/com/juick/service/component/SystemEvent.java +++ b/src/main/java/com/juick/service/component/SystemEvent.java @@ -21,7 +21,7 @@ import com.juick.www.api.SystemActivity; import org.springframework.context.ApplicationEvent; public class SystemEvent extends ApplicationEvent { - private SystemActivity activity; + private final SystemActivity activity; /** * Create a new ApplicationEvent. * diff --git a/src/main/java/com/juick/util/ImageUtils.java b/src/main/java/com/juick/util/ImageUtils.java index 38e1de08..d2158cca 100644 --- a/src/main/java/com/juick/util/ImageUtils.java +++ b/src/main/java/com/juick/util/ImageUtils.java @@ -46,8 +46,8 @@ import java.util.Iterator; public class ImageUtils { private static final Logger logger = LoggerFactory.getLogger(ImageUtils.class); - private String imgDir; - private String tmpDir; + private final String imgDir; + private final String tmpDir; public ImageUtils(String imgDir, String tmpDir) { this.imgDir = imgDir; diff --git a/src/main/java/com/juick/www/api/Post.java b/src/main/java/com/juick/www/api/Post.java index 886ae774..c94c7b30 100644 --- a/src/main/java/com/juick/www/api/Post.java +++ b/src/main/java/com/juick/www/api/Post.java @@ -155,7 +155,7 @@ public class Post { @PostMapping("/api/like") @ResponseStatus(value = HttpStatus.OK) - public Status doPostRecomm(@Visitor User visitor, @RequestParam Integer mid) throws Exception { + public Status doPostRecommendation(@Visitor User visitor, @RequestParam Integer mid) throws Exception { Optional message = messagesService.getMessage(mid); if (message.isEmpty()) { throw new HttpNotFoundException(); diff --git a/src/main/java/com/juick/www/api/Service.java b/src/main/java/com/juick/www/api/Service.java index cb385075..67e2fd01 100644 --- a/src/main/java/com/juick/www/api/Service.java +++ b/src/main/java/com/juick/www/api/Service.java @@ -83,7 +83,7 @@ public class Service { @Inject private ServerManager serverManager; - private Session session = Session.getDefaultInstance(new Properties()); + private final Session session = Session.getDefaultInstance(new Properties()); @ApiIgnore @PostMapping("/api/mail") -- cgit v1.2.3