All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jetbrains.pluginverifier.response.sarif.SarifInspectionConverter.kt Maven / Gradle / Ivy

Go to download

JetBrains Plugin Verifier Classes for IntelliJ Platform integration with API usage detection and reporting.

The newest version!
package com.jetbrains.pluginverifier.response.sarif

import com.jetbrains.pluginverifier.PluginVerificationResult


internal fun PluginVerificationResult.Verified.buildVerifiedInspections(): List {
  val pluginStructureWarningsInspection = buildPluginStructureWarningsInspection()
  val compatibilityWarningsInspection = buildCompatibilityWarningsInspection()
  val compatibilityProblemsInspection = buildCompatibilityProblemInspection()
  val apiUsagesInspections = buildApiUsageInspection()
  return pluginStructureWarningsInspection + compatibilityWarningsInspection + compatibilityProblemsInspection + apiUsagesInspections
}


internal fun PluginVerificationResult.InvalidPlugin.buildPluginStructureInspections(): List {
  return pluginStructureErrors.map {
    InspectionResult(
      ruleId = it.javaClass.simpleName,
      level = SeverityValue.ERROR.id,
      message = Message(it.message),
      locations = emptyList()
    )
  }
}

internal fun PluginVerificationResult.buildSingleInvocation(): List {
  return listOf(
    InspectionResult(
      ruleId = this.javaClass.simpleName,
      level = SeverityValue.ERROR.id,
      message = Message(this.verificationVerdict),
      locations = emptyList()
    )
  )
}


private fun PluginVerificationResult.Verified.buildApiUsageInspection(): List {
  val apiUsages = deprecatedUsages + experimentalApiUsages + internalApiUsages + nonExtendableApiUsages + overrideOnlyMethodUsages
  return apiUsages.map {
    InspectionResult(
      ruleId = it.javaClass.simpleName,
      level = SeverityValue.ERROR.id,
      message = Message(it.fullDescription),
      locations = emptyList()
    )
  }
}

private fun PluginVerificationResult.Verified.buildCompatibilityProblemInspection(): List {
  return compatibilityProblems.map {
    InspectionResult(
      ruleId = it.javaClass.simpleName,
      level = SeverityValue.ERROR.id,
      message = Message(it.fullDescription),
      locations = emptyList()
    )
  }
}

private fun PluginVerificationResult.Verified.buildCompatibilityWarningsInspection(): List {
  return compatibilityWarnings.map {
    InspectionResult(
      ruleId = it.javaClass.simpleName,
      level = SeverityValue.WARNING.id,
      message = Message(it.fullDescription),
      locations = emptyList()
    )
  }
}

private fun PluginVerificationResult.Verified.buildPluginStructureWarningsInspection(): List {
  return pluginStructureWarnings.map {
    InspectionResult(
      ruleId = it.javaClass.simpleName,
      level = SeverityValue.WARNING.id,
      message = Message(it.message),
      locations = emptyList()
    )
  }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy