Fix Autofix for ExplicitlyAnnotatedUnittestCheck (#150)
This commit is contained in:
parent
3b1a43a044
commit
fc72595eac
|
|
@ -28,8 +28,13 @@ extern(C++) class ExplicitlyAnnotatedUnittestCheck(AST) : BaseAnalyzerDmd
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!(d.storage_class & STC.safe || d.storage_class & STC.system))
|
if (!(d.storage_class & STC.safe || d.storage_class & STC.system))
|
||||||
addErrorMessage(cast(ulong) d.loc.linnum, cast(ulong) d.loc.charnum,
|
addErrorMessage(
|
||||||
KEY, MESSAGE);
|
cast(ulong) d.loc.linnum, cast(ulong) d.loc.charnum, KEY, MESSAGE,
|
||||||
|
[
|
||||||
|
AutoFix.insertionAt(d.loc.fileOffset, "@safe "),
|
||||||
|
AutoFix.insertionAt(d.loc.fileOffset, "@system ")
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
super.visit(d);
|
super.visit(d);
|
||||||
}
|
}
|
||||||
|
|
@ -73,27 +78,26 @@ unittest
|
||||||
}
|
}
|
||||||
}c, sac);
|
}c, sac);
|
||||||
|
|
||||||
// TODO: Check and fix
|
|
||||||
//// nested
|
//// nested
|
||||||
//assertAutoFix(q{
|
assertAutoFix(q{
|
||||||
//unittest {} // fix:0
|
unittest {} // fix:0
|
||||||
//pure nothrow @nogc unittest {} // fix:0
|
pure nothrow @nogc unittest {} // fix:0
|
||||||
|
|
||||||
//struct Foo
|
struct Foo
|
||||||
//{
|
{
|
||||||
//unittest {} // fix:1
|
unittest {} // fix:1
|
||||||
//pure nothrow @nogc unittest {} // fix:1
|
pure nothrow @nogc unittest {} // fix:1
|
||||||
//}
|
}
|
||||||
//}c, q{
|
}c, q{
|
||||||
//@safe unittest {} // fix:0
|
@safe unittest {} // fix:0
|
||||||
//pure nothrow @nogc @safe unittest {} // fix:0
|
pure nothrow @nogc @safe unittest {} // fix:0
|
||||||
|
|
||||||
//struct Foo
|
struct Foo
|
||||||
//{
|
{
|
||||||
//@system unittest {} // fix:1
|
@system unittest {} // fix:1
|
||||||
//pure nothrow @nogc @system unittest {} // fix:1
|
pure nothrow @nogc @system unittest {} // fix:1
|
||||||
//}
|
}
|
||||||
//}c, sac);
|
}c, sac, true);
|
||||||
|
|
||||||
stderr.writeln("Unittest for ExplicitlyAnnotatedUnittestCheck passed.");
|
stderr.writeln("Unittest for ExplicitlyAnnotatedUnittestCheck passed.");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue