Use new config name override instead of breaking existing ini
This commit is contained in:
parent
2c82155812
commit
67e0f8a9e4
|
@ -1,5 +1,5 @@
|
|||
; Configure which static analysis checks are enabled
|
||||
[dscanner.analysis.config.StaticAnalysisConfig]
|
||||
[analysis.config.StaticAnalysisConfig]
|
||||
; Check variable, class, struct, interface, union, and function names against t
|
||||
; he Phobos style guide
|
||||
style_check="disabled"
|
||||
|
|
2
dub.json
2
dub.json
|
@ -14,7 +14,7 @@
|
|||
"dependencies" : {
|
||||
"libdparse": "~>0.8.0-alpha.5",
|
||||
"dsymbol" : "~>0.3.0-alpha.3",
|
||||
"inifiled" : "~>1.1.0",
|
||||
"inifiled" : "~>1.2.0",
|
||||
"emsi_containers" : "~>0.6.0",
|
||||
"libddoc" : "~>0.3.0-beta.1",
|
||||
"stdx-allocator" : "~>2.77.0"
|
||||
|
|
2
inifiled
2
inifiled
|
@ -1 +1 @@
|
|||
Subproject commit e15038a5c265a9fdaea354476e7759d04e8d0bf9
|
||||
Subproject commit 971c5356388a73ebbf69e32f7f5e97cfc06cdcff
|
|
@ -54,7 +54,7 @@ StaticAnalysisConfig disabledConfig()
|
|||
return config;
|
||||
}
|
||||
|
||||
@INI("Configure which static analysis checks are enabled")
|
||||
@INI("Configure which static analysis checks are enabled", "analysis.config.StaticAnalysisConfig")
|
||||
struct StaticAnalysisConfig
|
||||
{
|
||||
@INI("Check variable, class, struct, interface, union, and function names against the Phobos style guide")
|
||||
|
|
|
@ -68,7 +68,6 @@ else
|
|||
bool printVersion;
|
||||
bool explore;
|
||||
string errorFormat;
|
||||
bool patchConfig;
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -97,8 +96,7 @@ else
|
|||
"muffinButton", &muffin,
|
||||
"explore", &explore,
|
||||
"skipTests", &skipTests,
|
||||
"errorFormat|f", &errorFormat,
|
||||
"patchConfig", &patchConfig);
|
||||
"errorFormat|f", &errorFormat);
|
||||
//dfmt on
|
||||
}
|
||||
catch (ConvException e)
|
||||
|
@ -235,11 +233,7 @@ else
|
|||
StaticAnalysisConfig config = defaultStaticAnalysisConfig();
|
||||
string s = configLocation is null ? getConfigurationLocation() : configLocation;
|
||||
if (s.exists())
|
||||
{
|
||||
if (hasWrongIniFileSection(s, patchConfig))
|
||||
return 0;
|
||||
readINIFile(config, s);
|
||||
}
|
||||
if (skipTests)
|
||||
config.enabled2SkipTests;
|
||||
if (report)
|
||||
|
@ -472,41 +466,3 @@ string getConfigurationLocation()
|
|||
|
||||
return getDefaultConfigurationLocation();
|
||||
}
|
||||
|
||||
|
||||
/// Patch the INI file to v0.5.0 format.
|
||||
//TODO: remove this from v0.6.0
|
||||
bool hasWrongIniFileSection(string configFilename, bool patch)
|
||||
{
|
||||
import std.string : indexOf;
|
||||
import std.array : replace;
|
||||
|
||||
bool result;
|
||||
|
||||
static immutable v1 = "analysis.config.StaticAnalysisConfig";
|
||||
static immutable v2 = "dscanner.analysis.config.StaticAnalysisConfig";
|
||||
|
||||
char[] c = cast(char[]) readFile(configFilename);
|
||||
try if (c.indexOf(v2) < 0)
|
||||
{
|
||||
if (!patch)
|
||||
{
|
||||
writeln("warning, the configuration file `", configFilename, "` contains an outdated property");
|
||||
writeln("change manually [", v1, "] to [", v2, "]" );
|
||||
writeln("or restart D-Scanner with the `--patchConfig` option");
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
c = replace(c, v1, v2);
|
||||
std.file.write(configFilename, c);
|
||||
writeln("the configuration file `", configFilename, "` has been updated correctly");
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
stderr.writeln("error encountered when trying to verify the INI file compatibility");
|
||||
throw e;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue