Skip to content

Commit

Permalink
Revert detekt changes with upgraded version 1.21.0 (#527)
Browse files Browse the repository at this point in the history
Signed-off-by: Rupal Mahajan <maharup@amazon.com>

Signed-off-by: Rupal Mahajan <maharup@amazon.com>
  • Loading branch information
rupal-bq authored Oct 31, 2022
1 parent c45371f commit 2c56b2f
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 23 deletions.
13 changes: 13 additions & 0 deletions reports-scheduler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ buildscript {
classpath "${opensearch_group}.gradle:build-tools:${opensearch_version}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}"
classpath "org.jetbrains.kotlin:kotlin-allopen:${kotlin_version}"
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.21.0"
classpath "org.jacoco:org.jacoco.agent:0.8.5"
}
}
Expand All @@ -56,9 +57,16 @@ apply plugin: 'idea'
apply plugin: 'opensearch.opensearchplugin'
apply plugin: 'opensearch.pluginzip'
apply plugin: 'opensearch.testclusters'
apply plugin: 'io.gitlab.arturbosch.detekt'
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'org.jetbrains.kotlin.plugin.allopen'

configurations.all {
resolutionStrategy {
force 'org.yaml:snakeyaml:1.32'
}
}

def usingRemoteCluster = System.properties.containsKey('tests.rest.cluster') || System.properties.containsKey('tests.cluster')
def usingMultiNode = project.properties.containsKey('numNodes')

Expand Down Expand Up @@ -105,6 +113,11 @@ configurations {
testRuntime
}

detekt {
config = files("detekt.yml")
buildUponDefaultConfig = true
}

configurations.testCompile {
exclude module: "securemock"
}
Expand Down
5 changes: 5 additions & 0 deletions reports-scheduler/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ style:
ReturnCount:
active: true
max: 10
complexity:
LongMethod:
threshold: 120
NestedBlockDepth:
threshold: 5
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ internal object ReportDefinitionsIndex {
const val REPORT_DEFINITIONS_INDEX_NAME = ".opendistro-reports-definitions"
private const val REPORT_DEFINITIONS_MAPPING_FILE_NAME = "report-definitions-mapping.yml"
private const val REPORT_DEFINITIONS_SETTINGS_FILE_NAME = "report-definitions-settings.yml"
private const val MAPPING_TYPE = "_doc"

private lateinit var client: Client
private lateinit var clusterService: ClusterService
Expand Down Expand Up @@ -75,10 +74,12 @@ internal object ReportDefinitionsIndex {
log.info("$LOG_PREFIX:Index $REPORT_DEFINITIONS_INDEX_NAME creation Acknowledged")
} else {
Metrics.REPORT_DEFINITION_CREATE_SYSTEM_ERROR.counter.increment()
throw IllegalStateException("$LOG_PREFIX:Index $REPORT_DEFINITIONS_INDEX_NAME creation not Acknowledged")
error("$LOG_PREFIX:Index $REPORT_DEFINITIONS_INDEX_NAME creation not Acknowledged")
}
} catch (exception: ResourceAlreadyExistsException) {
log.warn("message: ${exception.message}")
} catch (exception: Exception) {
if (exception !is ResourceAlreadyExistsException && exception.cause !is ResourceAlreadyExistsException) {
if (exception.cause !is ResourceAlreadyExistsException) {
Metrics.REPORT_DEFINITION_CREATE_SYSTEM_ERROR.counter.increment()
throw exception
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ internal object ReportInstancesIndex {
private const val REPORT_INSTANCES_INDEX_NAME = ".opendistro-reports-instances"
private const val REPORT_INSTANCES_MAPPING_FILE_NAME = "report-instances-mapping.yml"
private const val REPORT_INSTANCES_SETTINGS_FILE_NAME = "report-instances-settings.yml"
private const val MAPPING_TYPE = "_doc"

private lateinit var client: Client
private lateinit var clusterService: ClusterService
Expand Down Expand Up @@ -74,10 +73,12 @@ internal object ReportInstancesIndex {
if (response.isAcknowledged) {
log.info("$LOG_PREFIX:Index $REPORT_INSTANCES_INDEX_NAME creation Acknowledged")
} else {
throw IllegalStateException("$LOG_PREFIX:Index $REPORT_INSTANCES_INDEX_NAME creation not Acknowledged")
error("$LOG_PREFIX:Index $REPORT_INSTANCES_INDEX_NAME creation not Acknowledged")
}
} catch (exception: ResourceAlreadyExistsException) {
log.warn("message: ${exception.message}")
} catch (exception: Exception) {
if (exception !is ResourceAlreadyExistsException && exception.cause !is ResourceAlreadyExistsException) {
if (exception.cause !is ResourceAlreadyExistsException) {
throw exception
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ internal data class ReportDefinition(
val configIds: List<String>
) : ToXContentObject {
internal companion object {
private const val DELIVERY_FORMAT_TAG = "deliveryFormat"
private const val TITLE_TAG = "title"
private const val TEXT_DESCRIPTION_TAG = "textDescription"
private const val HTML_DESCRIPTION_TAG = "htmlDescription"
Expand All @@ -382,7 +381,6 @@ internal data class ReportDefinition(
* @return created Delivery object
*/
fun parse(parser: XContentParser): Delivery {
var recipients: List<String> = listOf()
var title: String? = null
var textDescription: String? = null
var htmlDescription: String? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal object SecurityAccess {
SpecialPermission.check()
return try {
AccessController.doPrivileged(operation)
} catch (e: PrivilegedActionException) {
} catch (@Suppress("SwallowedException") e: PrivilegedActionException) {
throw (e.cause as Exception?)!!
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ internal object PluginSettings {
try {
settings = Settings.builder().loadFromPath(defaultSettingYmlFile).build()
} catch (exception: IOException) {
log.warn("$LOG_PREFIX:Failed to load ${defaultSettingYmlFile.toAbsolutePath()}")
log.warn("$LOG_PREFIX:Failed to load ${defaultSettingYmlFile.toAbsolutePath()} message:${exception.message}")
}
}
// Initialize the settings values to default values
Expand Down

This file was deleted.

0 comments on commit 2c56b2f

Please sign in to comment.