Skip to content

Commit

Permalink
use klint instead of prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
robfrank committed Nov 18, 2024
1 parent 596078c commit 87103c7
Show file tree
Hide file tree
Showing 154 changed files with 25,205 additions and 21,678 deletions.
166 changes: 85 additions & 81 deletions .mvn/wrapper/MavenWrapperDownloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,96 +36,100 @@

public class MavenWrapperDownloader {

private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL =
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
private static final String WRAPPER_VERSION = "0.5.6";

/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH = ".mvn/wrapper/maven-wrapper.properties";
/** Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. */
private static final String DEFAULT_DOWNLOAD_URL =
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION
+ "/maven-wrapper-"
+ WRAPPER_VERSION
+ ".jar";

/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH = ".mvn/wrapper/maven-wrapper.jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to use
* instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";

/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
/** Path where the maven-wrapper.jar will be saved to. */
private static final String MAVEN_WRAPPER_JAR_PATH = ".mvn/wrapper/maven-wrapper.jar";

public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";

// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if (mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());

File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdirs()) {
System.out.println("- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if (mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);

private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(
new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
}
);
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '"
+ outputFile.getParentFile().getAbsolutePath()
+ "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}

private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(
new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}
22 changes: 12 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ repos:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.2
hooks:
- id: prettier
additional_dependencies:
- [email protected]
args:
- --write
- --list-different
- --ignore-unknown
# - repo: https://github.com/pre-commit/mirrors-prettier
# rev: v3.0.2
# hooks:
# - id: prettier
# additional_dependencies:
# - [email protected]
# args:
# - --write
# - --list-different
# - --ignore-unknown
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.14.0
hooks:
- id: pretty-format-kotlin
args: [--autofix]
- id: pretty-format-java
args: [--autofix]
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ package com.arcadeanalytics.provider
* @author Roberto Franchini
*/
interface DataSourceGraphDataProvider : DataSourceProvider {

/**
* Test the connection to the given {@link DataSourceInfo}
* @param dataSource to be tested
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import com.arcadeanalytics.data.SpritePlayer
* @author Roberto Franchini
*/
interface DataSourceGraphProvider : DataSourceProvider {

fun provideTo(dataSource: DataSourceInfo, player: SpritePlayer)
fun provideTo(
dataSource: DataSourceInfo,
player: SpritePlayer,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,5 @@ data class DataSourceMetadata(
)

interface DataSourceMetadataProvider : DataSourceProvider {

fun fetchMetadata(dataSource: DataSourceInfo): DataSourceMetadata
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ class DataSourceProviderFactory<T : DataSourceProvider>(
private val clazz: Class<T>,
pluginPath: String = "./plugins",
) {

private val log = LoggerFactory.getLogger(this::class.java)

private val dataProviders: MutableMap<String, T> = mutableMapOf()

init {
log.info("services for:: {}", clazz.simpleName)

Files.walk(Paths.get(pluginPath))
Files
.walk(Paths.get(pluginPath))
.asSequence()
.filter { path -> Files.isRegularFile(path) }
.map { path ->
Expand Down Expand Up @@ -69,13 +69,12 @@ class DataSourceProviderFactory<T : DataSourceProvider>(

fun provides(): Set<String> = dataProviders.keys

private fun decorate(provider: T): T {
return when (provider) {
private fun decorate(provider: T): T =
when (provider) {
is DataSourceMetadataProvider -> SshMetadataProviderDecorator(provider as DataSourceMetadataProvider) as T
is DataSourceGraphDataProvider -> SshDataProviderDecorator(provider as DataSourceGraphDataProvider) as T
is DataSourceGraphProvider -> SshGraphProviderDecorator(provider as DataSourceGraphProvider) as T
is DataSourceTableDataProvider -> SshTableDataProviderDecorator(provider as DataSourceTableDataProvider) as T
else -> provider
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,21 @@ package com.arcadeanalytics.provider

const val TABLE_CLASS = "Table"

data class QueryParam(val name: String, val type: String, val value: String)
data class QueryParam(
val name: String,
val type: String,
val value: String,
)

typealias QueryParams = List<QueryParam>

inline fun String.prefixIfAbsent(prefix: String): String {
return if (this.startsWith(prefix)) this else prefix + this
}
inline fun String.prefixIfAbsent(prefix: String): String = if (this.startsWith(prefix)) this else prefix + this

/**
* Interface to be implemented by specialized data providers
* @author Roberto Franchini
*/
interface DataSourceTableDataProvider : DataSourceProvider {

fun fetchData(
dataSource: DataSourceInfo,
query: String,
Expand Down
22 changes: 12 additions & 10 deletions common/src/main/kotlin/com/arcadeanalytics/provider/GraphData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
*/
package com.arcadeanalytics.provider

data class Position(private val x: Double, private val y: Double)
data class Position(
private val x: Double,
private val y: Double,
)

data class Data(
val id: String,
Expand Down Expand Up @@ -47,19 +50,18 @@ data class GraphData(
val edges: Set<CytoData>,
val truncated: Boolean = false,
) {

companion object {

/**
* Null object
*/
@JvmStatic
val EMPTY = GraphData(
emptyMap(),
emptyMap(),
emptySet(),
emptySet(),
false,
)
val EMPTY =
GraphData(
emptyMap(),
emptyMap(),
emptySet(),
emptySet(),
false,
)
}
}
Loading

0 comments on commit 87103c7

Please sign in to comment.