Enable checkstyle's Indentation module

master
jvoisin 5 years ago committed by GitHub
parent fabed228da
commit 7578ee9537
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 62
      airsonic-main/src/main/java/org/airsonic/player/TomcatApplication.java
  2. 2
      airsonic-main/src/main/java/org/airsonic/player/controller/HelpController.java
  3. 6
      airsonic-main/src/main/java/org/airsonic/player/controller/ImportPlaylistController.java
  4. 2
      airsonic-main/src/main/java/org/airsonic/player/controller/MainController.java
  5. 4
      airsonic-main/src/main/java/org/airsonic/player/controller/RecoverController.java
  6. 4
      airsonic-main/src/main/java/org/airsonic/player/controller/SettingsController.java
  7. 2
      airsonic-main/src/main/java/org/airsonic/player/controller/UploadController.java
  8. 2
      airsonic-main/src/main/java/org/airsonic/player/controller/UserSettingsController.java
  9. 4
      airsonic-main/src/main/java/org/airsonic/player/dao/AbstractDao.java
  10. 8
      airsonic-main/src/main/java/org/airsonic/player/dao/RatingDao.java
  11. 4
      airsonic-main/src/main/java/org/airsonic/player/domain/SearchResult.java
  12. 6
      airsonic-main/src/main/java/org/airsonic/player/security/GlobalSecurityConfig.java
  13. 4
      airsonic-main/src/main/java/org/airsonic/player/security/JWTAuthenticationProvider.java
  14. 10
      airsonic-main/src/main/java/org/airsonic/player/security/JWTRequestParameterProcessingFilter.java
  15. 6
      airsonic-main/src/main/java/org/airsonic/player/service/PodcastService.java
  16. 6
      airsonic-main/src/main/java/org/airsonic/player/service/search/SearchServiceImpl.java
  17. 28
      airsonic-main/src/main/java/org/airsonic/player/service/upnp/DispatchingContentDirectory.java
  18. 10
      airsonic-main/src/main/java/org/airsonic/player/util/FileUtil.java
  19. 1
      checkstyle.xml

@ -11,36 +11,36 @@ public class TomcatApplication {
public static void configure(TomcatEmbeddedServletContainerFactory tomcatFactory) { public static void configure(TomcatEmbeddedServletContainerFactory tomcatFactory) {
tomcatFactory.addContextCustomizers((TomcatContextCustomizer) context -> { tomcatFactory.addContextCustomizers((TomcatContextCustomizer) context -> {
StandardJarScanFilter standardJarScanFilter = new StandardJarScanFilter(); StandardJarScanFilter standardJarScanFilter = new StandardJarScanFilter();
standardJarScanFilter.setTldScan("dwr-*.jar,jstl-*.jar,spring-security-taglibs-*.jar,spring-web-*.jar,spring-webmvc-*.jar,string-*.jar,taglibs-standard-impl-*.jar,tomcat-annotations-api-*.jar,tomcat-embed-jasper-*.jar"); standardJarScanFilter.setTldScan("dwr-*.jar,jstl-*.jar,spring-security-taglibs-*.jar,spring-web-*.jar,spring-webmvc-*.jar,string-*.jar,taglibs-standard-impl-*.jar,tomcat-annotations-api-*.jar,tomcat-embed-jasper-*.jar");
standardJarScanFilter.setTldSkip("*"); standardJarScanFilter.setTldSkip("*");
context.getJarScanner().setJarScanFilter(standardJarScanFilter); context.getJarScanner().setJarScanFilter(standardJarScanFilter);
boolean development = (System.getProperty("airsonic.development") != null); boolean development = (System.getProperty("airsonic.development") != null);
// Increase the size and time before eviction of the Tomcat // Increase the size and time before eviction of the Tomcat
// cache so that resources aren't uncompressed too often. // cache so that resources aren't uncompressed too often.
// See https://github.com/jhipster/generator-jhipster/issues/3995 // See https://github.com/jhipster/generator-jhipster/issues/3995
StandardRoot resources = new StandardRoot(); StandardRoot resources = new StandardRoot();
if (development) { if (development) {
resources.setCachingAllowed(false); resources.setCachingAllowed(false);
} else { } else {
resources.setCacheMaxSize(100000); resources.setCacheMaxSize(100000);
resources.setCacheObjectMaxSize(4000); resources.setCacheObjectMaxSize(4000);
resources.setCacheTtl(24 * 3600 * 1000); // 1 day, in milliseconds resources.setCacheTtl(24 * 3600 * 1000); // 1 day, in milliseconds
} }
context.setResources(resources); context.setResources(resources);
// Put Jasper in production mode so that JSP aren't recompiled // Put Jasper in production mode so that JSP aren't recompiled
// on each request. // on each request.
// See http://stackoverflow.com/questions/29653326/spring-boot-application-slow-because-of-jsp-compilation // See http://stackoverflow.com/questions/29653326/spring-boot-application-slow-because-of-jsp-compilation
Container jsp = context.findChild("jsp"); Container jsp = context.findChild("jsp");
if (jsp instanceof Wrapper) { if (jsp instanceof Wrapper) {
((Wrapper) jsp).addInitParameter("development", Boolean.toString(development)); ((Wrapper) jsp).addInitParameter("development", Boolean.toString(development));
} }
}); });
} }
} }

@ -103,7 +103,7 @@ public class HelpController {
String current; String current;
while((current = reader.readLine()) != null) { while((current = reader.readLine()) != null) {
if (lines.size() >= LOG_LINES_TO_SHOW) { if (lines.size() >= LOG_LINES_TO_SHOW) {
break; break;
} }
lines.add(0, current); lines.add(0, current);
} }

@ -57,8 +57,8 @@ public class ImportPlaylistController {
@PostMapping @PostMapping
protected String handlePost(RedirectAttributes redirectAttributes, protected String handlePost(RedirectAttributes redirectAttributes,
HttpServletRequest request HttpServletRequest request
) throws Exception { ) throws Exception {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
try { try {
@ -79,7 +79,7 @@ public class ImportPlaylistController {
String format = StringUtils.lowerCase(FilenameUtils.getExtension(item.getName())); String format = StringUtils.lowerCase(FilenameUtils.getExtension(item.getName()));
String username = securityService.getCurrentUsername(request); String username = securityService.getCurrentUsername(request);
Playlist playlist = playlistService.importPlaylist(username, playlistName, fileName, Playlist playlist = playlistService.importPlaylist(username, playlistName, fileName,
item.getInputStream(), null); item.getInputStream(), null);
map.put("playlist", playlist); map.put("playlist", playlist);
} }
} }

@ -171,7 +171,7 @@ public class MainController {
} }
return new ModelAndView(view, "model", map); return new ModelAndView(view, "model", map);
} }
private <T> boolean trimToSize(Boolean showAll, List<T> list, int userPaginationPreference) { private <T> boolean trimToSize(Boolean showAll, List<T> list, int userPaginationPreference) {
boolean trimmed = false; boolean trimmed = false;

@ -75,8 +75,8 @@ public class RecoverController {
} else { } else {
StringBuilder sb = new StringBuilder(PASSWORD_LENGTH); StringBuilder sb = new StringBuilder(PASSWORD_LENGTH);
for(int i=0; i<PASSWORD_LENGTH; i++) { for(int i=0; i<PASSWORD_LENGTH; i++) {
int index = random.nextInt(SYMBOLS.length()); int index = random.nextInt(SYMBOLS.length());
sb.append(SYMBOLS.charAt(index)); sb.append(SYMBOLS.charAt(index));
} }
String password = sb.toString(); String password = sb.toString();

@ -42,7 +42,7 @@ public class SettingsController {
@Autowired @Autowired
private SecurityService securityService; private SecurityService securityService;
@GetMapping @GetMapping
protected ModelAndView handleRequestInternal(HttpServletRequest request) throws Exception { protected ModelAndView handleRequestInternal(HttpServletRequest request) throws Exception {
User user = securityService.getCurrentUser(request); User user = securityService.getCurrentUser(request);
@ -51,6 +51,6 @@ public class SettingsController {
String view = user.isAdminRole() ? "musicFolderSettings" : "personalSettings"; String view = user.isAdminRole() ? "musicFolderSettings" : "personalSettings";
return new ModelAndView(new RedirectView(view)); return new ModelAndView(new RedirectView(view));
} }
} }

@ -174,7 +174,7 @@ public class UploadController {
ZipEntry entry = (ZipEntry) entries.nextElement(); ZipEntry entry = (ZipEntry) entries.nextElement();
File entryFile = new File(file.getParentFile(), entry.getName()); File entryFile = new File(file.getParentFile(), entry.getName());
if (!entryFile.toPath().normalize().startsWith(file.getParentFile().toPath())) { if (!entryFile.toPath().normalize().startsWith(file.getParentFile().toPath())) {
throw new Exception("Bad zip filename: " + StringUtil.toHtml(entryFile.getPath())); throw new Exception("Bad zip filename: " + StringUtil.toHtml(entryFile.getPath()));
} }
if (!entry.isDirectory()) { if (!entry.isDirectory()) {

@ -76,7 +76,7 @@ public class UserSettingsController {
protected String displayForm(HttpServletRequest request, Model model) throws Exception { protected String displayForm(HttpServletRequest request, Model model) throws Exception {
UserSettingsCommand command; UserSettingsCommand command;
if(!model.containsAttribute("command")) { if(!model.containsAttribute("command")) {
command = new UserSettingsCommand(); command = new UserSettingsCommand();
User user = getUser(request); User user = getUser(request);
if (user != null) { if (user != null) {

@ -60,8 +60,8 @@ public class AbstractDao {
} }
protected String questionMarks(String columns) { protected String questionMarks(String columns) {
int numberOfColumns = StringUtils.countMatches(columns, ",") + 1; int numberOfColumns = StringUtils.countMatches(columns, ",") + 1;
return StringUtils.repeat("?", ", ", numberOfColumns); return StringUtils.repeat("?", ", ", numberOfColumns);
} }
protected String prefix(String columns, String prefix) { protected String prefix(String columns, String prefix) {

@ -51,10 +51,10 @@ public class RatingDao extends AbstractDao {
} }
Map<String, Object> args = new HashMap<>(); Map<String, Object> args = new HashMap<>();
args.put("type", MediaFile.MediaType.ALBUM.name()); args.put("type", MediaFile.MediaType.ALBUM.name());
args.put("folders", MusicFolder.toPathList(musicFolders)); args.put("folders", MusicFolder.toPathList(musicFolders));
args.put("count", count); args.put("count", count);
args.put("offset", offset); args.put("offset", offset);
String sql = "select user_rating.path from user_rating, media_file " + String sql = "select user_rating.path from user_rating, media_file " +
"where user_rating.path=media_file.path and media_file.present and media_file.type = :type and media_file.folder in (:folders) " + "where user_rating.path=media_file.path and media_file.present and media_file.type = :type and media_file.folder in (:folders) " +

@ -59,11 +59,11 @@ public class SearchResult {
this.offset = offset; this.offset = offset;
} }
public int getTotalHits() { public int getTotalHits() {
return totalHits; return totalHits;
} }
public void setTotalHits(int totalHits) { public void setTotalHits(int totalHits) {
this.totalHits = totalHits; this.totalHits = totalHits;
} }
} }

@ -74,9 +74,9 @@ public class GlobalSecurityConfig extends GlobalAuthenticationConfigurerAdapter
} }
private static String generateRememberMeKey() { private static String generateRememberMeKey() {
byte[] array = new byte[32]; byte[] array = new byte[32];
new SecureRandom().nextBytes(array); new SecureRandom().nextBytes(array);
return new String(array); return new String(array);
} }
@Configuration @Configuration

@ -46,9 +46,7 @@ public class JWTAuthenticationProvider implements AuthenticationProvider {
// TODO:AD This is super unfortunate, but not sure there is a better way when using JSP // TODO:AD This is super unfortunate, but not sure there is a better way when using JSP
if(StringUtils.contains(authentication.getRequestedPath(), "/WEB-INF/jsp/")) { if(StringUtils.contains(authentication.getRequestedPath(), "/WEB-INF/jsp/")) {
logger.warn("BYPASSING AUTH FOR WEB-INF page"); logger.warn("BYPASSING AUTH FOR WEB-INF page");
} else } else if(!roughlyEqual(path.asString(), authentication.getRequestedPath())) {
if(!roughlyEqual(path.asString(), authentication.getRequestedPath())) {
throw new InsufficientAuthenticationException("Credentials not valid for path " + authentication throw new InsufficientAuthenticationException("Credentials not valid for path " + authentication
.getRequestedPath() + ". They are valid for " + path.asString()); .getRequestedPath() + ". They are valid for " + path.asString());
} }

@ -31,11 +31,11 @@ public class JWTRequestParameterProcessingFilter implements Filter {
} }
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException, IOException, ServletException { public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException, IOException, ServletException {
Optional<JWTAuthenticationToken> token = findToken(request); Optional<JWTAuthenticationToken> token = findToken(request);
if(token.isPresent()) { if(token.isPresent()) {
return authenticationManager.authenticate(token.get()); return authenticationManager.authenticate(token.get());
} }
throw new AuthenticationServiceException("Invalid auth method"); throw new AuthenticationServiceException("Invalid auth method");
} }
private static Optional<JWTAuthenticationToken> findToken(HttpServletRequest request) { private static Optional<JWTAuthenticationToken> findToken(HttpServletRequest request) {

@ -74,10 +74,10 @@ public class PodcastService {
private static final Logger LOG = LoggerFactory.getLogger(PodcastService.class); private static final Logger LOG = LoggerFactory.getLogger(PodcastService.class);
private static final DateFormat[] RSS_DATE_FORMATS = {new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US), private static final DateFormat[] RSS_DATE_FORMATS = {new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US),
new SimpleDateFormat("dd MMM yyyy HH:mm:ss Z", Locale.US)}; new SimpleDateFormat("dd MMM yyyy HH:mm:ss Z", Locale.US)};
private static final Namespace[] ITUNES_NAMESPACES = {Namespace.getNamespace("http://www.itunes.com/DTDs/Podcast-1.0.dtd"), private static final Namespace[] ITUNES_NAMESPACES = {Namespace.getNamespace("http://www.itunes.com/DTDs/Podcast-1.0.dtd"),
Namespace.getNamespace("http://www.itunes.com/dtds/podcast-1.0.dtd")}; Namespace.getNamespace("http://www.itunes.com/dtds/podcast-1.0.dtd")};
private final ExecutorService refreshExecutor; private final ExecutorService refreshExecutor;
private final ExecutorService downloadExecutor; private final ExecutorService downloadExecutor;
@ -704,7 +704,7 @@ public class PodcastService {
File channelDir = new File(podcastDir, StringUtil.fileSystemSafe(channel.getTitle())); File channelDir = new File(podcastDir, StringUtil.fileSystemSafe(channel.getTitle()));
if (!podcastDir.canWrite()) { if (!podcastDir.canWrite()) {
throw new RuntimeException("The podcasts directory " + podcastDir + " isn't writeable."); throw new RuntimeException("The podcasts directory " + podcastDir + " isn't writeable.");
} }
if (!channelDir.exists()) { if (!channelDir.exists()) {

@ -168,7 +168,7 @@ public class SearchServiceImpl implements SearchService {
Query query = queryFactory.getRandomSongs(criteria); Query query = queryFactory.getRandomSongs(criteria);
return createRandomDocsList(criteria.getCount(), searcher, query, return createRandomDocsList(criteria.getCount(), searcher, query,
(dist, id) -> util.addIgnoreNull(dist, SONG, id)); (dist, id) -> util.addIgnoreNull(dist, SONG, id));
} catch (IOException e) { } catch (IOException e) {
LOG.error("Failed to search or random songs.", e); LOG.error("Failed to search or random songs.", e);
@ -191,7 +191,7 @@ public class SearchServiceImpl implements SearchService {
Query query = queryFactory.getRandomAlbums(musicFolders); Query query = queryFactory.getRandomAlbums(musicFolders);
return createRandomDocsList(count, searcher, query, return createRandomDocsList(count, searcher, query,
(dist, id) -> util.addIgnoreNull(dist, ALBUM, id)); (dist, id) -> util.addIgnoreNull(dist, ALBUM, id));
} catch (IOException e) { } catch (IOException e) {
LOG.error("Failed to search for random albums.", e); LOG.error("Failed to search for random albums.", e);
@ -214,7 +214,7 @@ public class SearchServiceImpl implements SearchService {
Query query = queryFactory.getRandomAlbumsId3(musicFolders); Query query = queryFactory.getRandomAlbumsId3(musicFolders);
return createRandomDocsList(count, searcher, query, return createRandomDocsList(count, searcher, query,
(dist, id) -> util.addIgnoreNull(dist, ALBUM_ID3, id)); (dist, id) -> util.addIgnoreNull(dist, ALBUM_ID3, id));
} catch (IOException e) { } catch (IOException e) {
LOG.error("Failed to search for random albums.", e); LOG.error("Failed to search for random albums.", e);

@ -153,20 +153,20 @@ public class DispatchingContentDirectory extends CustomContentDirectory {
private UpnpContentProcessor findProcessor(String type) { private UpnpContentProcessor findProcessor(String type) {
switch(type) { switch(type) {
case CONTAINER_ID_ROOT: case CONTAINER_ID_ROOT:
return getRootProcessor(); return getRootProcessor();
case CONTAINER_ID_PLAYLIST_PREFIX: case CONTAINER_ID_PLAYLIST_PREFIX:
return getPlaylistProcessor(); return getPlaylistProcessor();
case CONTAINER_ID_FOLDER_PREFIX: case CONTAINER_ID_FOLDER_PREFIX:
return getMediaFileProcessor(); return getMediaFileProcessor();
case CONTAINER_ID_ALBUM_PREFIX: case CONTAINER_ID_ALBUM_PREFIX:
return getAlbumProcessor(); return getAlbumProcessor();
case CONTAINER_ID_RECENT_PREFIX: case CONTAINER_ID_RECENT_PREFIX:
return getRecentAlbumProcessor(); return getRecentAlbumProcessor();
case CONTAINER_ID_ARTIST_PREFIX: case CONTAINER_ID_ARTIST_PREFIX:
return getArtistProcessor(); return getArtistProcessor();
case CONTAINER_ID_GENRE_PREFIX: case CONTAINER_ID_GENRE_PREFIX:
return getGenreProcessor(); return getGenreProcessor();
} }
return null; return null;
} }

@ -140,13 +140,7 @@ public final class FileUtil {
} }
private static <T> T timed(FileTask<T> task) { private static <T> T timed(FileTask<T> task) {
// long t0 = System.nanoTime(); return task.execute();
// try {
return task.execute();
// } finally {
// long t1 = System.nanoTime();
// LOG.debug((t1 - t0) / 1000L + " microsec, " + task);
// }
} }
private abstract static class FileTask<T> { private abstract static class FileTask<T> {
@ -166,4 +160,4 @@ public final class FileUtil {
return name + ", " + file; return name + ", " + file;
} }
} }
} }

@ -24,6 +24,7 @@
<module name="EmptyStatement"/> <module name="EmptyStatement"/>
<module name="EqualsAvoidNull"/> <module name="EqualsAvoidNull"/>
<module name="EqualsHashCode"/> <module name="EqualsHashCode"/>
<module name="Indentation"/>
<module name="InnerAssignment"/> <module name="InnerAssignment"/>
<module name="RedundantImport"/> <module name="RedundantImport"/>
<module name="StringLiteralEquality"/> <module name="StringLiteralEquality"/>

Loading…
Cancel
Save