Check if logger invocations don't use unoptimal invocations, eg.
concatenation `debug("a=" + a)` instead of lambda use `debug {"a=" + a}`
Unfortunately to avoid defining dependencies in many places and having
circural dependencies it was necessarry to reorganize the maven module
structure. The goal was to have `sources` module with production code and
`build` module with build-time tooling (detekt rules among them).
Issue-ID: DCAEGEN2-1002
Change-Id: I36e677b98972aaae6905d722597cbce5e863d201
Signed-off-by: Piotr Jaszczyk <piotr.jaszczyk@nokia.com>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ ============LICENSE_START=======================================================
+ ~ dcaegen2-collectors-veshv
+ ~ ================================================================================
+ ~ Copyright (C) 2018 NOKIA
+ ~ ================================================================================
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ ~ ============LICENSE_END=========================================================
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <licenses>
+ <license>
+ <name>The Apache Software License, Version 2.0</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+ </license>
+ </licenses>
+
+ <parent>
+ <groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
+ <artifactId>hv-collector-build</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <artifactId>hv-collector-analysis</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <description>VES HighVolume Collector :: Code analysis configuration</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>io.gitlab.arturbosch.detekt</groupId>
+ <artifactId>detekt-api</artifactId>
+ <version>${detekt.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-stdlib-jdk8</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-reflect</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-compiler-embeddable</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-script-runtime</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-script-util</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>io.gitlab.arturbosch.detekt</groupId>
+ <artifactId>detekt-test</artifactId>
+ <version>${detekt.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.spek</groupId>
+ <artifactId>spek-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.spek</groupId>
+ <artifactId>spek-junit-platform-engine</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-test</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
+ <testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <configuration>
+ <encoding>UTF-8</encoding>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>kotlin-maven-plugin</artifactId>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <version>${kotlin.version}</version>
+ <configuration>
+ <jvmTarget>1.8</jvmTarget>
+ </configuration>
+ <executions>
+ <execution>
+ <id>compile</id>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ <configuration>
+ <sourceDirs>
+ <source>${project.build.sourceDirectory}</source>
+ </sourceDirs>
+ </configuration>
+ </execution>
+ <execution>
+ <id>test-compile</id>
+ <goals>
+ <goal>test-compile</goal>
+ </goals>
+ <configuration>
+ <sourceDirs>
+ <source>${project.build.testSourceDirectory}</source>
+ </sourceDirs>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * dcaegen2-collectors-veshv
+ * ================================================================================
+ * Copyright (C) 2018 NOKIA
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcae.collectors.veshv.analysis
+
+import io.gitlab.arturbosch.detekt.api.CodeSmell
+import io.gitlab.arturbosch.detekt.api.Config
+import io.gitlab.arturbosch.detekt.api.Debt
+import io.gitlab.arturbosch.detekt.api.Entity
+import io.gitlab.arturbosch.detekt.api.Issue
+import io.gitlab.arturbosch.detekt.api.Rule
+import io.gitlab.arturbosch.detekt.api.Severity
+import org.jetbrains.kotlin.com.intellij.psi.PsiElement
+import org.jetbrains.kotlin.psi.KtCallExpression
+import org.jetbrains.kotlin.psi.KtOperationExpression
+import org.jetbrains.kotlin.psi.KtStringTemplateExpression
+import org.jetbrains.kotlin.psi.KtValueArgumentList
+import org.jetbrains.kotlin.psi.psiUtil.anyDescendantOfType
+
+/**
+ * @author Piotr Jaszczyk <piotr.jaszczyk@nokia.com>
+ * @since November 2018
+ */
+class SuboptimalLoggerUsage(config: Config) : Rule(config) {
+
+ override val issue = Issue(javaClass.simpleName,
+ Severity.Performance,
+ """
+ Reports usage of unoptimized logger calls.
+ In Kotlin every method call (including logger calls) is eagerly evaluated by default. That means that
+ each argument will be evaluated even if loglevel is higher than in current call. The most common way of
+ mitigating this issue is to use lazy loading by means of lambda expressions, so instead of
+ log.debug("a=${'$'}a") we can write log.debug{ "a=${'$'}a" }. Logging string literals is fine - no
+ additional computation will be performed.""".trimIndent(),
+ Debt(mins = 10))
+
+ private val loggerNames = config.valueOrDefault("loggerNames", DEFAULT_LOGGER_NAMES).split(",")
+
+ private val loggingMethods = config.valueOrDefault("loggingMethodNames", DEFAULT_LOGGING_METHOD_NAMES).split(",")
+
+ override fun visitCallExpression(expression: KtCallExpression) {
+ val targetObject = expression.parent.firstChild
+ val methodName = expression.firstChild
+
+ logExpressionArguments(targetObject, methodName)
+ ?.let(this::checkGettingWarningMessage)
+ ?.let { reportCodeSmell(expression, it) }
+ }
+
+ private fun logExpressionArguments(targetObject: PsiElement, methodName: PsiElement) =
+ if (isLogExpression(targetObject, methodName))
+ methodName.nextSibling as? KtValueArgumentList
+ else null
+
+ private fun isLogExpression(targetObject: PsiElement, methodName: PsiElement) =
+ loggerNames.any(targetObject::textMatches) && loggingMethods.any(methodName::textMatches)
+
+ private fun checkGettingWarningMessage(args: KtValueArgumentList) = when {
+ args.anyDescendantOfType<KtOperationExpression> { true } ->
+ "should not use any operators in logging expression"
+ args.anyDescendantOfType<KtCallExpression> { true } ->
+ "should not call anything in logging expression"
+ args.anyDescendantOfType<KtStringTemplateExpression> { it.hasInterpolation() } ->
+ "should not use string interpolation in logging expression"
+ else -> null
+ }
+
+ private fun reportCodeSmell(expression: KtCallExpression, message: String) {
+ report(CodeSmell(issue, Entity.from(expression), message))
+ }
+
+ companion object {
+ const val DEFAULT_LOGGER_NAMES = "logger,LOGGER,log,LOG"
+ const val DEFAULT_LOGGING_METHOD_NAMES = "trace,debug,info,warn,error,severe"
+ }
+}
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * dcaegen2-collectors-veshv
+ * ================================================================================
+ * Copyright (C) 2018 NOKIA
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcae.collectors.veshv.analysis
+
+import io.gitlab.arturbosch.detekt.api.Config
+import io.gitlab.arturbosch.detekt.api.RuleSet
+import io.gitlab.arturbosch.detekt.api.RuleSetProvider
+
+/**
+ * @author Piotr Jaszczyk <piotr.jaszczyk@nokia.com>
+ * @since November 2018
+ */
+class VesHvRuleSetProvider : RuleSetProvider {
+ override val ruleSetId: String
+ get() = "HvVesCustomRules"
+
+ override fun instance(config: Config) = RuleSet(ruleSetId, listOf(SuboptimalLoggerUsage(config)))
+
+}
--- /dev/null
+org.onap.dcae.collectors.veshv.analysis.VesHvRuleSetProvider
\ No newline at end of file
WildcardImport:
active: true
excludeImports: 'java.util.*,kotlinx.android.synthetic.*'
+
+HvVesCustomRules:
+ active: true
+ SuboptimalLoggerUsage:
+ active: true
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * dcaegen2-collectors-veshv
+ * ================================================================================
+ * Copyright (C) 2018 NOKIA
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcae.collectors.veshv.analysis
+
+import io.gitlab.arturbosch.detekt.api.Config
+import io.gitlab.arturbosch.detekt.test.TestConfig
+import io.gitlab.arturbosch.detekt.test.assertThat
+import io.gitlab.arturbosch.detekt.test.compileAndLint
+import org.jetbrains.spek.api.Spek
+import org.jetbrains.spek.api.dsl.describe
+import org.jetbrains.spek.api.dsl.it
+import org.jetbrains.spek.api.dsl.xdescribe
+
+/**
+ * @author Piotr Jaszczyk <piotr.jaszczyk></piotr.jaszczyk>@nokia.com>
+ * @since November 2018
+ */
+internal class SuboptimalLoggerUsageTest : Spek({
+
+ fun checkPassingCase(code: String, cut: SuboptimalLoggerUsage = SuboptimalLoggerUsage(Config.empty)) {
+ describe(code) {
+ val findings = cut.compileAndLint(CodeSamples.code(code))
+
+ it("should pass") {
+ assertThat(findings).isEmpty()
+ }
+ }
+ }
+
+ fun checkFailingCase(code: String, cut: SuboptimalLoggerUsage = SuboptimalLoggerUsage(Config.empty)) {
+ describe(code) {
+ val findings = cut.compileAndLint(CodeSamples.code(code))
+
+ it("should fail") {
+ assertThat(findings).isNotEmpty()
+ }
+ }
+ }
+
+ describe("passing cases") {
+ checkPassingCase(CodeSamples.noConcatCall)
+ checkPassingCase(CodeSamples.exceptionCall)
+ checkPassingCase(CodeSamples.lambdaCall)
+ checkPassingCase(CodeSamples.lambdaFunctionCall)
+ checkPassingCase(CodeSamples.lambdaExceptionCall)
+ }
+
+
+ describe("failing cases") {
+ checkFailingCase(CodeSamples.plainConcatCall)
+ checkFailingCase(CodeSamples.expansionCall)
+ checkFailingCase(CodeSamples.plainConcatExceptionCall)
+ checkFailingCase(CodeSamples.expansionExceptionCall)
+ }
+
+ describe("custom configuration") {
+ val cut = SuboptimalLoggerUsage(TestConfig(mapOf("loggerNames" to "l,lo", "loggingMethodNames" to "print")))
+ val strangeLogger = """
+ val l = object {
+ fun print(m: String) { }
+ }
+ val lo = l
+ """.trimIndent()
+
+ checkPassingCase(CodeSamples.plainConcatCall, cut)
+
+ checkPassingCase("""
+ $strangeLogger
+ l.print("n")""".trimIndent(), cut)
+
+ checkFailingCase("""
+ $strangeLogger
+ l.print("n=" + n)""".trimIndent(), cut)
+
+ checkFailingCase("""
+ $strangeLogger
+ lo.print("n=${'$'}n")""".trimIndent(), cut)
+ }
+})
+
+object CodeSamples {
+ private val codeBefore = """
+ object logger {
+ fun debug(msg: String) { println(msg) }
+ fun debug(msg: String, ex: Throwable) { println(msg + ". Cause: " + ex) }
+ fun debug(msg: () -> String) { println(msg()) }
+ fun debug(ex: Throwable, msg: () -> String) { println(msg() + ". Cause: " + ex) }
+ }
+
+ fun execute(n: Integer) {
+ val ex = Exception()
+
+ """.trimIndent()
+ private const val codeAfter = """}"""
+
+ const val noConcatCall = """logger.debug("Executing...")"""
+ const val exceptionCall = """logger.debug("Fail", ex)"""
+ const val lambdaCall = """logger.debug{ "n=${'$'}n" }"""
+ const val lambdaFunctionCall = """logger.debug { n.toString() }"""
+ const val lambdaExceptionCall = """logger.debug(ex) { "epic fail on n=" + n }"""
+
+ const val plainConcatCall = """logger.debug("n=" + n)"""
+ const val expansionCall = """logger.debug("n=${'$'}n")"""
+ const val plainConcatExceptionCall = """logger.debug("Fail. n=" + n, ex)"""
+ const val expansionExceptionCall = """logger.debug("Fail. n=${'$'}n", ex)"""
+
+
+ fun code(core: String) = codeBefore + core + codeAfter
+}
\ No newline at end of file
--- /dev/null
+org.jetbrains.kotlin.script.jsr223.KotlinJsr223JvmLocalScriptEngineFactory
\ No newline at end of file
<parent>
<groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
- <artifactId>ves-hv-collector</artifactId>
+ <artifactId>hv-collector-build</artifactId>
<version>1.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
~ limitations under the License.
~ ============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
<modelVersion>4.0.0</modelVersion>
<licenses>
</license>
</licenses>
- <groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
- <artifactId>hv-collector-analysis</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <description>VES HighVolume Collector :: Code analysis configuration</description>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-deploy-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
+ <parent>
+ <groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
+ <artifactId>ves-hv-collector</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-resources-plugin</artifactId>
- <version>3.1.0</version>
- <configuration>
- <encoding>UTF-8</encoding>
- </configuration>
- </plugin>
- </plugins>
- </build>
+ <artifactId>hv-collector-build</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <description>VES HighVolume Collector :: Build-time modules</description>
+ <packaging>pom</packaging>
-</project>
\ No newline at end of file
+ <modules>
+ <module>hv-collector-analysis</module>
+ <module>hv-collector-coverage</module>
+ </modules>
+</project>
<packaging>pom</packaging>
<modules>
- <module>hv-collector-analysis</module>
- <module>hv-collector-core</module>
- <module>hv-collector-coverage</module>
- <module>hv-collector-ct</module>
- <module>hv-collector-dcae-app-simulator</module>
- <module>hv-collector-domain</module>
- <module>hv-collector-health-check</module>
- <module>hv-collector-main</module>
- <module>hv-collector-ssl</module>
- <module>hv-collector-test-utils</module>
- <module>hv-collector-utils</module>
- <module>hv-collector-ves-message-generator</module>
- <module>hv-collector-xnf-simulator</module>
+ <module>build</module>
+ <module>sources</module>
</modules>
<properties>
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
<build-helper-maven-plugin.version>1.7</build-helper-maven-plugin.version>
<jacoco.version>0.8.2</jacoco.version>
- <jacoco.minimum.coverage>60</jacoco.minimum.coverage>
+ <detekt.version>1.0.0-RC11</detekt.version>
<!-- Protocol buffers -->
<protobuf.version>3.6.1</protobuf.version>
<failIfMissingUnitTests>false</failIfMissingUnitTests>
<failIfMissingComponentTests>false</failIfMissingComponentTests>
<skipAnalysis>true</skipAnalysis>
+ <jacoco.minimum.coverage>60</jacoco.minimum.coverage>
<!-- Docker -->
<skipDocker>false</skipDocker>
<version>${kotlin.version}</version>
<configuration>
<jvmTarget>1.8</jvmTarget>
- <experimentalCoroutines>enable</experimentalCoroutines>
</configuration>
<executions>
<execution>
</plugin>
</plugins>
</pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.17</version>
- <dependencies>
- <dependency>
- <groupId>org.onap.oparent</groupId>
- <artifactId>checkstyle</artifactId>
- <version>1.1.1</version>
- </dependency>
- </dependencies>
- <executions>
- <execution>
- <!-- To override oparent configuration different id must be used
- We need to override it to include .kt files in check. -->
- <id>check-license-kotlin</id>
- <goals>
- <goal>check</goal>
- </goals>
- <phase>process-sources</phase>
- <configuration>
- <configLocation>onap-checkstyle/check-license.xml</configLocation>
- <includeResources>false</includeResources>
- <includeTestSourceDirectory>true</includeTestSourceDirectory>
- <includeTestResources>false</includeTestResources>
- <includes>**\/*.kt</includes>
- <consoleOutput>true</consoleOutput>
- <!--<failOnViolation>false</failOnViolation>-->
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>1.8</version>
- <executions>
- <execution>
- <!-- This can be run separately with mvn antrun:run@detekt -->
- <id>detekt</id>
- <phase>verify</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <target name="detekt" unless="${skipAnalysis}">
- <java taskname="detekt" dir="${basedir}" fork="true" failonerror="true" classname="io.gitlab.arturbosch.detekt.cli.Main" classpathref="maven.plugin.classpath">
- <arg value="--input"/>
- <arg value="${basedir}/src/main/kotlin"/>
- <arg value="--config-resource"/>
- <arg value="onap-detekt-config.yml"/>
- <arg value="--filters"/>
- <arg value=".*/target/.*,.*/resources/.*"/>
- <arg value="--report"/>
- <arg value="detekt-report:${basedir}/target/reports"/>
- <arg value="--baseline"/>
- <arg value="${basedir}/target/reports/baseline.xml"/>
- </java>
- </target>
- </configuration>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>io.gitlab.arturbosch.detekt</groupId>
- <artifactId>detekt-cli</artifactId>
- <version>1.0.0-RC11</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>hv-collector-analysis</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>${kotlin.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-compiler-embeddable</artifactId>
+ <version>${kotlin.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-script-runtime</artifactId>
+ <version>${kotlin.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-script-util</artifactId>
+ <version>${kotlin.version}</version>
+ <scope>runtime</scope>
+ </dependency>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-core</artifactId>
<parent>
<groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
- <artifactId>ves-hv-collector</artifactId>
+ <artifactId>hv-collector-sources</artifactId>
<version>1.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
private fun findRoute(msg: VesMessage): Mono<RoutedMessage> = omitWhenNone((router::findDestination)(msg))
private fun <V> omitWhenNone(it: Option<V>): Mono<V> = it.fold(
- { Mono.empty() },
+ {
+ logger.info("ommiting the message" + 5)
+ Mono.empty() },
{ Mono.just(it) })
private fun releaseBuffersMemory(wireChunkDecoder: WireChunkDecoder) = wireChunkDecoder.release()
<parent>
<groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
- <artifactId>ves-hv-collector</artifactId>
+ <artifactId>hv-collector-sources</artifactId>
<version>1.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
- <artifactId>ves-hv-collector</artifactId>
+ <artifactId>hv-collector-sources</artifactId>
<version>1.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
- <artifactId>ves-hv-collector</artifactId>
+ <artifactId>hv-collector-sources</artifactId>
<version>1.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
- <artifactId>ves-hv-collector</artifactId>
+ <artifactId>hv-collector-sources</artifactId>
<version>1.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
- <artifactId>ves-hv-collector</artifactId>
+ <artifactId>hv-collector-sources</artifactId>
<version>1.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
- <artifactId>ves-hv-collector</artifactId>
+ <artifactId>hv-collector-sources</artifactId>
<version>1.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
- <artifactId>ves-hv-collector</artifactId>
+ <artifactId>hv-collector-sources</artifactId>
<version>1.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
- <artifactId>ves-hv-collector</artifactId>
+ <artifactId>hv-collector-sources</artifactId>
<version>1.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
import kotlin.reflect.KClass
import org.slf4j.LoggerFactory
-@Suppress("TooManyFunctions")
+@Suppress("TooManyFunctions", "SuboptimalLoggerUsage")
class Logger(val logger: org.slf4j.Logger) {
constructor(clazz: KClass<out Any>) : this(LoggerFactory.getLogger(clazz.java))
constructor(name: String) : this(LoggerFactory.getLogger(name))
<parent>
<groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
- <artifactId>ves-hv-collector</artifactId>
+ <artifactId>hv-collector-sources</artifactId>
<version>1.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<parent>
<groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
- <artifactId>ves-hv-collector</artifactId>
+ <artifactId>hv-collector-sources</artifactId>
<version>1.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ ============LICENSE_START=======================================================
+ ~ dcaegen2-collectors-veshv
+ ~ ================================================================================
+ ~ Copyright (C) 2018 NOKIA
+ ~ ================================================================================
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ ~ ============LICENSE_END=========================================================
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <licenses>
+ <license>
+ <name>The Apache Software License, Version 2.0</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+ </license>
+ </licenses>
+
+ <parent>
+ <groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
+ <artifactId>ves-hv-collector</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <artifactId>hv-collector-sources</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <description>VES HighVolume Collector :: Sources</description>
+ <packaging>pom</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>2.17</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>checkstyle</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <!-- To override oparent configuration different id must be used
+ We need to override it to include .kt files in check. -->
+ <id>check-license-kotlin</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <phase>process-sources</phase>
+ <configuration>
+ <configLocation>onap-checkstyle/check-license.xml</configLocation>
+ <includeResources>false</includeResources>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
+ <includeTestResources>false</includeTestResources>
+ <includes>**\/*.kt</includes>
+ <consoleOutput>true</consoleOutput>
+ <!--<failOnViolation>false</failOnViolation>-->
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.8</version>
+ <executions>
+ <execution>
+ <!-- This can be run separately with mvn antrun:run@detekt -->
+ <id>detekt</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <target name="detekt" unless="${skipAnalysis}">
+ <java taskname="detekt" dir="${basedir}" fork="true" failonerror="true" classname="io.gitlab.arturbosch.detekt.cli.Main" classpathref="maven.plugin.classpath">
+ <arg value="--input"/>
+ <arg value="${basedir}/src/main/kotlin"/>
+ <arg value="--config-resource"/>
+ <arg value="onap-detekt-config.yml"/>
+ <arg value="--filters"/>
+ <arg value=".*/target/.*,.*/resources/.*"/>
+ <arg value="--report"/>
+ <arg value="html:${basedir}/target/detekt-report.html"/>
+ </java>
+ </target>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>io.gitlab.arturbosch.detekt</groupId>
+ <artifactId>detekt-cli</artifactId>
+ <version>${detekt.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>hv-collector-analysis</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+
+ <modules>
+ <module>hv-collector-core</module>
+ <module>hv-collector-ct</module>
+ <module>hv-collector-dcae-app-simulator</module>
+ <module>hv-collector-domain</module>
+ <module>hv-collector-health-check</module>
+ <module>hv-collector-main</module>
+ <module>hv-collector-ssl</module>
+ <module>hv-collector-test-utils</module>
+ <module>hv-collector-utils</module>
+ <module>hv-collector-ves-message-generator</module>
+ <module>hv-collector-xnf-simulator</module>
+ </modules>
+</project>