[hardcoded-passwords] QD-8998 provide custom configuration to HardcodedPasswords from qodana yaml

(cherry picked from commit 78721044fad224d56dd3439c577bffd0098ff8a8)

IJ-CR-139669

GitOrigin-RevId: 1cc78b4bf95df3c1aa87d102a4a9a39721acb9cf
This commit is contained in:
Mikhail Shagvaliev
2024-07-08 19:38:45 +02:00
committed by intellij-monorepo-bot
parent 10f9b09d83
commit 3268d0564f
2 changed files with 8 additions and 7 deletions

View File

@@ -10,8 +10,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.yaml.snakeyaml.parser.ParserException;
import java.io.File;
public abstract class InspectionProfileLoaderBase<T extends InspectionProfileImpl> implements InspectionProfileLoader<T> {
protected Project project;
@@ -26,9 +24,6 @@ public abstract class InspectionProfileLoaderBase<T extends InspectionProfileImp
if (!YamlInspectionProfileImpl.isYamlFile(profilePath)) {
return null;
}
if (!new File(profilePath).isFile()) {
throw new InspectionApplicationException("Inspection profile '" + profilePath + "' does not exist");
}
try {
return YamlInspectionProfileImpl.loadFrom(project, profilePath, inspectionToolsSupplier, profileManager).buildEffectiveProfile();
}

View File

@@ -7,6 +7,7 @@ import com.intellij.codeInspection.ex.*
import com.intellij.codeInspection.inspectionProfile.YamlProfileUtils.createProfileCopy
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.guessProjectDir
import com.intellij.openapi.util.io.toCanonicalPath
import com.intellij.openapi.vfs.VfsUtilCore
import com.intellij.openapi.vfs.VirtualFile
@@ -119,8 +120,13 @@ class YamlInspectionProfileImpl private constructor(override val profileName: St
toolsSupplier: InspectionToolsSupplier = ProjectInspectionToolRegistrar.getInstance(project),
profileManager: BaseInspectionProfileManager = ProjectInspectionProfileManager.getInstance(project)
): YamlInspectionProfileImpl {
val configFile = File(filePath).absoluteFile
require(configFile.exists()) { "File does not exist: ${configFile.canonicalPath}" }
val configFile = if (File(filePath).isAbsolute) {
File(filePath).absoluteFile
} else {
project.guessProjectDir()?.toNioPath()?.toFile()?.resolve(filePath)?.absoluteFile
}
require(configFile?.exists() == true) { "File does not exist: ${configFile!!.canonicalPath}" }
requireNotNull(configFile)
val includeProvider: (Path) -> Reader = {
val includePath = Path.of(configFile.parent).resolve(it)