ݺߣ

ݺߣShare a Scribd company logo
Àâòîìàòè÷åñêèé ïîèñê îøèáîê
Âëàäèìèð Êîøåëåâ
Èíñòèòóò ñèñòåìíîãî ïðîãðàììèðîâàíèÿ ÐÀÍ
vedun@ispras.ru
21 ôåâðàëÿ 2017 ã.
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 1 / 29
Ïëàí
1 Ââåäåíèå
2 Âåðèôèêàöèÿ
3 Roslyn: èñïîëüçóåì íà ïðàêòèêå
4 Ñòàòè÷åñêèé àíàëèç
5 Äèíàìè÷åñêèé àíàëèç
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 2 / 29
Ââåäåíèå
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 3 / 29
Îá ÈÑÏ ÐÀÍ
×åì ìû çàíèìàåìñÿ:
Àíàëèç èñõîäíîãî êîäà ïðîãðàìì äëÿ ïîèñêà îøèáîê:
C/C++
Java
C#
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 4 / 29
Îá ÈÑÏ ÐÀÍ
×åì ìû çàíèìàåìñÿ:
Àíàëèç èñõîäíîãî êîäà ïðîãðàìì äëÿ ïîèñêà îøèáîê:
C/C++
Java
C#
Àíàëèç áèíàðíîãî êîäà
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 4 / 29
Îá ÈÑÏ ÐÀÍ
×åì ìû çàíèìàåìñÿ:
Àíàëèç èñõîäíîãî êîäà ïðîãðàìì äëÿ ïîèñêà îøèáîê:
C/C++
Java
C#
Àíàëèç áèíàðíîãî êîäà
Ðàçðàáîòêà GCC
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 4 / 29
Îá ÈÑÏ ÐÀÍ
×åì ìû çàíèìàåìñÿ:
Àíàëèç èñõîäíîãî êîäà ïðîãðàìì äëÿ ïîèñêà îøèáîê:
C/C++
Java
C#
Àíàëèç áèíàðíîãî êîäà
Ðàçðàáîòêà GCC
Ðàçðàáîòêà QEMU
...
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 4 / 29
Òåîðåìà Ðàéñà
 ÷åì çàêëþ÷àåòñÿ îñíîâíàÿ ñëîæíîñòü àíàëèçà ïðîãðàìì?
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 5 / 29
Òåîðåìà Ðàéñà
 ÷åì çàêëþ÷àåòñÿ îñíîâíàÿ ñëîæíîñòü àíàëèçà ïðîãðàìì?
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 5 / 29
Ïîñòàíîâêè çàäà÷è ïðè ïîèñêå áàãîâ
Íàõîäèì âñå áàãè è èìååì ëîæíûå ñðàáàòûâàíèÿ:
Âåðèôèêàöèÿ
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 6 / 29
Ïîñòàíîâêè çàäà÷è ïðè ïîèñêå áàãîâ
Íàõîäèì âñå áàãè è èìååì ëîæíûå ñðàáàòûâàíèÿ:
Âåðèôèêàöèÿ
Íàõîäèì íå âñå áàãè è èìååì ëîæíûå ñðàáàòûâàíèÿ:
Ñòàòè÷åñêèé àíàëèç
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 6 / 29
Ïîñòàíîâêè çàäà÷è ïðè ïîèñêå áàãîâ
Íàõîäèì âñå áàãè è èìååì ëîæíûå ñðàáàòûâàíèÿ:
Âåðèôèêàöèÿ
Íàõîäèì íå âñå áàãè è èìååì ëîæíûå ñðàáàòûâàíèÿ:
Ñòàòè÷åñêèé àíàëèç
Íàõîäèì òîëüêî áàãè, íî íàéäåì ÿâíî íå âñå:
Äèíàìè÷åñêèé àíàëèç
Ñìåøàííûé àíàëèç
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 6 / 29
Âåðèôèêàöèÿ
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 7 / 29
Âåðèôèêàöèÿ: ïîèñê íåèíèöèàëèçèðîâàííûõ ïåðåìåííûõ
public string Foo(string a, string b) {
string min;
int cmpResult = a.CompareTo(b);
if (cmpResult < 0)
min = a;
if (cmpResult >= 0)
min = b;
return min;
}
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 8 / 29
Âåðèôèêàöèÿ: ïîèñê íåèíèöèàëèçèðîâàííûõ ïåðåìåííûõ
public string Foo(string a, string b) {
string min;
int cmpResult = a.CompareTo(b);
if (cmpResult < 0) // False
min = a;
if (cmpResult >= 0) // False
min = b;
return min;
}
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 9 / 29
"Âåðèôèêàöèÿ"â CodeContracts
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 10 / 29
Ïðèìåð êîíòðàêòîâ
public string Greet(string [] args)
{
Contract.Requires(args != null);
Contract.Requires(args.Length > 0);
Contract.Requires(args [0] != null);
Contract.Ensures(Contract.Result <string >().Length
> 5);
Console.WriteLine("Hello , {0}!", args [0]);
return "abacaba" + args [0];
}
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 11 / 29
Roslyn: èñïîëüçóåì íà ïðàêòèêå
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 12 / 29
Ïàðó ñëîâ î Roslyn
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 13 / 29
Ïðàêòè÷åñêîå ïðèìåíåíèå Roslyn: áîðåìñÿ ñ boilerplate
Entitas - The Entity Component System Framework for C# and Unity
Çàäà÷à: àâòîìàòè÷åñêè ãåíåðèðîâàòü boilerplate êîä äëÿ ðàáîòû ñ
êîìïîíåíòàìè.
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 14 / 29
Ïðàêòè÷åñêîå ïðèìåíåíèå Roslyn: áîðåìñÿ ñ boilerplate
Entitas - The Entity Component System Framework for C# and Unity
Çàäà÷à: àâòîìàòè÷åñêè ãåíåðèðîâàòü boilerplate êîä äëÿ ðàáîòû ñ
êîìïîíåíòàìè.
public class PositionComponent : IComponent
{
public float X;
public float Y;
}
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 14 / 29
Ïðàêòè÷åñêîå ïðèìåíåíèå Roslyn: áîðåìñÿ ñ boilerplate
Entitas - The Entity Component System Framework for C# and Unity
Çàäà÷à: àâòîìàòè÷åñêè ãåíåðèðîâàòü boilerplate êîä äëÿ ðàáîòû ñ
êîìïîíåíòàìè.
public class PositionComponent : IComponent
{
public float X;
public float Y;
}
public void AddPosition(float newX , float newY) {
var component =
CreateComponent <PositionComponent >
(BattleComponentsLookup.Position);
component.X = newX;
component.Y = newY;
AddComponent(BattleComponentsLookup.Position ,
component);
}
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 14 / 29
Ãåíåðàöèÿ ÷åðåç Reection
var types = Assembly
.GetAssembly(typeof(MainClass))
.GetTypes ();
foreach (var type in types)
{
Process(type);
}
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 15 / 29
Ãåíåðàöèÿ ÷åðåç Reection
var types = Assembly
.GetAssembly(typeof(MainClass))
.GetTypes ();
foreach (var type in types)
{
Process(type);
}
Ãëàâíàÿ ïðîáëåìà: ãåíåðàöèÿ ðàáîòàåò òîëüêî åñëè ïðîåêò êîìïèëèðóåòñÿ.
Åñëè âû õîòèòå ðåôàêòîðèòü, íóæíî èñïðàâëÿòü âñå îøèáêè â
ñãåíåðèðîâàííîì êîäå.
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 15 / 29
Ãåíåðàöèÿ ÷åðåç Roslyn
using (var workspace = MSBuildWorkspace.Create ())
{
var solution =
workspace.OpenSolutionAsync(path).Result;
foreach (var project in solution.Projects){
var compilation =
project.GetCompilationAsync ().Result;
var allTypes =
compilation.GetSymbolsWithName(x = true ,
SymbolFilter.Type).OfType ITypeSymbol ();
foreach (var type in types)
Process(type)
}
}
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 16 / 29
Èñêëþ÷åíèå íà Mac/Mono
Unhandled Exception:
System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be
loaded.
at (wrapper managed -to-native) System.Reflection.Assembly:GetTypes
(System.Reflection.Assembly ,bool)
at System.Reflection.Assembly.GetTypes () [0 x00000] in
8f2c484307284b51944a1a13a14c0266 :0
at System.Reflection.Assembly+c__Iterator0.MoveNext () [0 x00021] in
8f2c484307284b51944a1a13a14c0266 :0
at System.Linq.Enumerable+WhereSelectEnumerableIterator `2[ TSource ,TResult ]. MoveNext ()
[0 x00078] in 63992662 b765477a898ef49cdcc99ee2 :0
at System.Linq.Enumerable+SelectManyIterator c__Iterator2 `2[ TSource ,TResult ]. MoveNext
() [0 x000bc] in 63992662 b765477a898ef49cdcc99ee2 :0
at System.Composition.TypedParts.TypedPartExportDescriptorProvider ..ctor
(System.Collections.Generic.IEnumerable `1[T] types ,
System.Composition.Convention.AttributedModelProvider attributeContext) [0 x00049]
in c091afde214c4b8e8efbbeb9d44062d4 :0
at System.Composition.Hosting.ContainerConfiguration.CreateContainer () [0 x00042] in
c091afde214c4b8e8efbbeb9d44062d4 :0
at Microsoft.CodeAnalysis.Host.Mef.MefHostServices.Create
(System.Collections.Generic.IEnumerable `1[T] assemblies) [0 x00019] in
947408 acdcbc4eba93cdb6a19d92fcd1 :0
at Microsoft.CodeAnalysis.Host.Mef.DesktopMefHostServices.get_DefaultServices ()
[0 x00011] in 2ba3a08d4fe0467c8c54c8bc37c61987 :0
at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.Create
(System.Collections.Generic.IDictionary `2[TKey ,TValue] properties) [0 x00000] in
2ba3a08d4fe0467c8c54c8bc37c61987 :0
at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.Create () [0 x00000] in
2ba3a08d4fe0467c8c54c8bc37c61987 :0
...
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 17 / 29
Ñòàòè÷åñêèé àíàëèç
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 18 / 29
Çà÷åì ðàçðàáîò÷èêàì íóæåí ñòàòè÷åñêèé àíàëèç
Ñòàòè÷åñêèé àíàëèç èñïîëüçóåòñÿ êàê äëÿ ïîèñêà îøèáîê äî
òåñòèðîâàíèÿ, òàê è äëÿ ïîèñêà îøèáîê, ïðîïóùåííûõ ïðè
òåñòèðîâàíèè
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 19 / 29
Çà÷åì ðàçðàáîò÷èêàì íóæåí ñòàòè÷åñêèé àíàëèç
Ñòàòè÷åñêèé àíàëèç èñïîëüçóåòñÿ êàê äëÿ ïîèñêà îøèáîê äî
òåñòèðîâàíèÿ, òàê è äëÿ ïîèñêà îøèáîê, ïðîïóùåííûõ ïðè
òåñòèðîâàíèè
×åì áîëüøå ðàçìåð êîìàíäû, òåì ýôôåêòèâíåå ðàáîòàåò
ñòàòè÷åñêèé àíàëèç
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 19 / 29
Çà÷åì ðàçðàáîò÷èêàì íóæåí ñòàòè÷åñêèé àíàëèç
Ñòàòè÷åñêèé àíàëèç èñïîëüçóåòñÿ êàê äëÿ ïîèñêà îøèáîê äî
òåñòèðîâàíèÿ, òàê è äëÿ ïîèñêà îøèáîê, ïðîïóùåííûõ ïðè
òåñòèðîâàíèè
×åì áîëüøå ðàçìåð êîìàíäû, òåì ýôôåêòèâíåå ðàáîòàåò
ñòàòè÷åñêèé àíàëèç
Ïðèìåíåíèå ñëîæíîãî ñòàòè÷åñêîãî àíàëèçà ïðåäïîëàãàåò
âûñîêóþ öåíó îøèáêè
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 19 / 29
Çà÷åì ðàçðàáîò÷èêàì íóæåí ñòàòè÷åñêèé àíàëèç
Ñòàòè÷åñêèé àíàëèç èñïîëüçóåòñÿ êàê äëÿ ïîèñêà îøèáîê äî
òåñòèðîâàíèÿ, òàê è äëÿ ïîèñêà îøèáîê, ïðîïóùåííûõ ïðè
òåñòèðîâàíèè
×åì áîëüøå ðàçìåð êîìàíäû, òåì ýôôåêòèâíåå ðàáîòàåò
ñòàòè÷åñêèé àíàëèç
Ïðèìåíåíèå ñëîæíîãî ñòàòè÷åñêîãî àíàëèçà ïðåäïîëàãàåò
âûñîêóþ öåíó îøèáêè
Ñòàòè÷åñêèé àíàëèç õîðîøî ñî÷åòàåòñÿ ñ CodeReview
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 19 / 29
Òðåáîâàíèÿ ê ñòàòè÷åñêèì àíàëèçàòîðàì
Âðåìÿ ðàáîòû
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 20 / 29
Òðåáîâàíèÿ ê ñòàòè÷åñêèì àíàëèçàòîðàì
Âðåìÿ ðàáîòû
Ñîîòíîøåíèå âûäàíî ïðåäóïðåæäåíèé/âíåñåíî èñïðàâëåíèé
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 20 / 29
Òðåáîâàíèÿ ê ñòàòè÷åñêèì àíàëèçàòîðàì
Âðåìÿ ðàáîòû
Ñîîòíîøåíèå âûäàíî ïðåäóïðåæäåíèé/âíåñåíî èñïðàâëåíèé
Ïîääåðæèâàåìûå êëàññû îøèáîê, âêëþ÷àÿ ïîäêëàññû
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 20 / 29
Òðåáîâàíèÿ ê ñòàòè÷åñêèì àíàëèçàòîðàì
Âðåìÿ ðàáîòû
Ñîîòíîøåíèå âûäàíî ïðåäóïðåæäåíèé/âíåñåíî èñïðàâëåíèé
Ïîääåðæèâàåìûå êëàññû îøèáîê, âêëþ÷àÿ ïîäêëàññû
Ïîíÿòíîñòü ñîîáùåíèé îá îøèáêàõ
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 20 / 29
Òðåáîâàíèÿ ê ñòàòè÷åñêèì àíàëèçàòîðàì
Âðåìÿ ðàáîòû
Ñîîòíîøåíèå âûäàíî ïðåäóïðåæäåíèé/âíåñåíî èñïðàâëåíèé
Ïîääåðæèâàåìûå êëàññû îøèáîê, âêëþ÷àÿ ïîäêëàññû
Ïîíÿòíîñòü ñîîáùåíèé îá îøèáêàõ
Èíòåãðàöèÿ ñ CI
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 20 / 29
Èíñòðóìåíòû ñòàòè÷åñêîãî àíàëèçà
Coverity
SharpChecker (íàø èíñòðóìåíò)
SonarLint
ReSharper
PVS-Studio
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 21 / 29
Coverity
Äå ôàêòî ñòàíäàðò êà÷åñòâà äëÿ èíñòðóìåíòîâ ñòàòè÷åñêîãî
àíàëèçà
Ïðîäàåòñÿ òîëüêî çà áîëüøèå äåíüãè
Áåñïëàòåí äëÿ OpenSource íà https://scan.coverity.com
Âñå âèäû àíàëèçà: AST, âíóòðèïðîöåäðóíûé, ìåæïðîöåäóðûíé
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 22 / 29
SharpChecker
Ñòàòè÷åñêèé àíàëèç íà îñíîâå Roslyn, ðàçðàáîòàííûé â ÈÑÏ ÐÀÍ.
Öåëü ïðîåêòà: ðàçðàáîòàòü èíñòðóìåíò, ñîîòâåòñòâóþùèé óðîâíþ
ëó÷øèõ ñîâðåìåííûõ ñòàòè÷åñêèõ àíàëèçàòîðîâ.
Âñå âèäû àíàëèçà: AST, âíóòðèïðîöåäðóíûé, ìåæïðîöåäóðûíé.
http://sharpchecker.ispras.ru
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 23 / 29
SonarLint for VisualStudio
Áåñïëàòíàÿ êîëëåêöèÿ àíàëèçàòîðîâ äëÿ Roslyn
Èíòåãðàöèÿ ñ SonarQube
Èíòåãðàöèÿ ñ ñáîðêîé msbuild
Áîëåå 100 AST àíàëèçàòîðîâ
Èíòåãðàöèÿ ñ Visual Studio
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 24 / 29
Ñðàâíåíèå ReSharper è PVS-Studio
ReSharper PVS-Studio
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 25 / 29
Ñðàâíåíèå ReSharper è PVS-Studio
ReSharper PVS-Studio
Êîëè÷åñòâî ñòàòåé íà
õàðáðàõàáðå çà ôåâðàëü
0 8
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 25 / 29
Ñðàâíåíèå ReSharper è PVS-Studio
ReSharper PVS-Studio
Êîëè÷åñòâî ñòàòåé íà
õàðáðàõàáðå çà ôåâðàëü
0 8
Íàëè÷èå AST-äåòåêòîðîâ Äà Äà
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 25 / 29
Ñðàâíåíèå ReSharper è PVS-Studio
ReSharper PVS-Studio
Êîëè÷åñòâî ñòàòåé íà
õàðáðàõàáðå çà ôåâðàëü
0 8
Íàëè÷èå AST-äåòåêòîðîâ Äà Äà
Íàëè÷èå âíóòðèïðîöåäóðíîãî
àíàëèçà ïîòîêîâ äàííûõ
Äà Íåò
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 25 / 29
Ñðàâíåíèå ReSharper è PVS-Studio
ReSharper PVS-Studio
Êîëè÷åñòâî ñòàòåé íà
õàðáðàõàáðå çà ôåâðàëü
0 8
Íàëè÷èå AST-äåòåêòîðîâ Äà Äà
Íàëè÷èå âíóòðèïðîöåäóðíîãî
àíàëèçà ïîòîêîâ äàííûõ
Äà Íåò
Àíàëèç âî âðåìÿ ðàçðàáîòêè Äà Íåò
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 25 / 29
Ñðàâíåíèå ReSharper è PVS-Studio
ReSharper PVS-Studio
Êîëè÷åñòâî ñòàòåé íà
õàðáðàõàáðå çà ôåâðàëü
0 8
Íàëè÷èå AST-äåòåêòîðîâ Äà Äà
Íàëè÷èå âíóòðèïðîöåäóðíîãî
àíàëèçà ïîòîêîâ äàííûõ
Äà Íåò
Àíàëèç âî âðåìÿ ðàçðàáîòêè Äà Íåò
Èíòåãðàöèÿ ñ CI Äà Äà
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 25 / 29
Ñðàâíåíèå ReSharper è PVS-Studio
ReSharper PVS-Studio
Êîëè÷åñòâî ñòàòåé íà
õàðáðàõàáðå çà ôåâðàëü
0 8
Íàëè÷èå AST-äåòåêòîðîâ Äà Äà
Íàëè÷èå âíóòðèïðîöåäóðíîãî
àíàëèçà ïîòîêîâ äàííûõ
Äà Íåò
Àíàëèç âî âðåìÿ ðàçðàáîòêè Äà Íåò
Èíòåãðàöèÿ ñ CI Äà Äà
Õîðîøàÿ äîêóìåíòàöèÿ Íåò Äà
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 25 / 29
Äèíàìè÷åñêèé àíàëèç
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 26 / 29
PEX / IntelliTest
http://www.pexforfun.com/
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 27 / 29
Èäåÿ ðàáîòû IntelliTest
Àëãîðèòì ðàáîòû:
çàïóñòèì ìåòîä ñ êàêèìè-íèáóäü ïàðàìåòðàìè;
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 28 / 29
Èäåÿ ðàáîòû IntelliTest
Àëãîðèòì ðàáîòû:
çàïóñòèì ìåòîä ñ êàêèìè-íèáóäü ïàðàìåòðàìè;
ïîñòðîèì ôîðìóëó, êîòîðàÿ îïèñûâàåò åãî âûïîëíåíèå;
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 28 / 29
Èäåÿ ðàáîòû IntelliTest
Àëãîðèòì ðàáîòû:
çàïóñòèì ìåòîä ñ êàêèìè-íèáóäü ïàðàìåòðàìè;
ïîñòðîèì ôîðìóëó, êîòîðàÿ îïèñûâàåò åãî âûïîëíåíèå;
ðåøèì çàäà÷ó: êàêèìè äîëæíû áûòü ïàðàìåòðû, ÷òîáû
âûïîëíåíèå ïðîøëî ïî äðóãîé âåòêå è óâåëè÷èëî ïîêðûòèå;
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 28 / 29
Èäåÿ ðàáîòû IntelliTest
Àëãîðèòì ðàáîòû:
çàïóñòèì ìåòîä ñ êàêèìè-íèáóäü ïàðàìåòðàìè;
ïîñòðîèì ôîðìóëó, êîòîðàÿ îïèñûâàåò åãî âûïîëíåíèå;
ðåøèì çàäà÷ó: êàêèìè äîëæíû áûòü ïàðàìåòðû, ÷òîáû
âûïîëíåíèå ïðîøëî ïî äðóãîé âåòêå è óâåëè÷èëî ïîêðûòèå;
çàïóñòèì ñ íîâûìè äàííûìè.
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 28 / 29
Ñïàñèáî çà âíèìàíèå!
Âëàäèìèð Êîøåëåâ
vedun@ispras.ru
Ññûëêè:
SharpChecker: http://sharpchecker.ispras.ru
Coverity: https://scan.coverity.com
SonarLint : http://www.sonarlint.org/visualstudio/
Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 29 / 29

More Related Content

Владимир Кошелев «Автоматический поиск ошибок»

  • 1. Àâòîìàòè÷åñêèé ïîèñê îøèáîê Âëàäèìèð Êîøåëåâ Èíñòèòóò ñèñòåìíîãî ïðîãðàììèðîâàíèÿ ÐÀÍ vedun@ispras.ru 21 ôåâðàëÿ 2017 ã. Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 1 / 29
  • 2. Ïëàí 1 Ââåäåíèå 2 Âåðèôèêàöèÿ 3 Roslyn: èñïîëüçóåì íà ïðàêòèêå 4 Ñòàòè÷åñêèé àíàëèç 5 Äèíàìè÷åñêèé àíàëèç Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 2 / 29
  • 3. Ââåäåíèå Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 3 / 29
  • 4. Îá ÈÑÏ ÐÀÍ ×åì ìû çàíèìàåìñÿ: Àíàëèç èñõîäíîãî êîäà ïðîãðàìì äëÿ ïîèñêà îøèáîê: C/C++ Java C# Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 4 / 29
  • 5. Îá ÈÑÏ ÐÀÍ ×åì ìû çàíèìàåìñÿ: Àíàëèç èñõîäíîãî êîäà ïðîãðàìì äëÿ ïîèñêà îøèáîê: C/C++ Java C# Àíàëèç áèíàðíîãî êîäà Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 4 / 29
  • 6. Îá ÈÑÏ ÐÀÍ ×åì ìû çàíèìàåìñÿ: Àíàëèç èñõîäíîãî êîäà ïðîãðàìì äëÿ ïîèñêà îøèáîê: C/C++ Java C# Àíàëèç áèíàðíîãî êîäà Ðàçðàáîòêà GCC Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 4 / 29
  • 7. Îá ÈÑÏ ÐÀÍ ×åì ìû çàíèìàåìñÿ: Àíàëèç èñõîäíîãî êîäà ïðîãðàìì äëÿ ïîèñêà îøèáîê: C/C++ Java C# Àíàëèç áèíàðíîãî êîäà Ðàçðàáîòêà GCC Ðàçðàáîòêà QEMU ... Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 4 / 29
  • 8. Òåîðåìà Ðàéñà  ÷åì çàêëþ÷àåòñÿ îñíîâíàÿ ñëîæíîñòü àíàëèçà ïðîãðàìì? Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 5 / 29
  • 9. Òåîðåìà Ðàéñà  ÷åì çàêëþ÷àåòñÿ îñíîâíàÿ ñëîæíîñòü àíàëèçà ïðîãðàìì? Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 5 / 29
  • 10. Ïîñòàíîâêè çàäà÷è ïðè ïîèñêå áàãîâ Íàõîäèì âñå áàãè è èìååì ëîæíûå ñðàáàòûâàíèÿ: Âåðèôèêàöèÿ Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 6 / 29
  • 11. Ïîñòàíîâêè çàäà÷è ïðè ïîèñêå áàãîâ Íàõîäèì âñå áàãè è èìååì ëîæíûå ñðàáàòûâàíèÿ: Âåðèôèêàöèÿ Íàõîäèì íå âñå áàãè è èìååì ëîæíûå ñðàáàòûâàíèÿ: Ñòàòè÷åñêèé àíàëèç Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 6 / 29
  • 12. Ïîñòàíîâêè çàäà÷è ïðè ïîèñêå áàãîâ Íàõîäèì âñå áàãè è èìååì ëîæíûå ñðàáàòûâàíèÿ: Âåðèôèêàöèÿ Íàõîäèì íå âñå áàãè è èìååì ëîæíûå ñðàáàòûâàíèÿ: Ñòàòè÷åñêèé àíàëèç Íàõîäèì òîëüêî áàãè, íî íàéäåì ÿâíî íå âñå: Äèíàìè÷åñêèé àíàëèç Ñìåøàííûé àíàëèç Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 6 / 29
  • 13. Âåðèôèêàöèÿ Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 7 / 29
  • 14. Âåðèôèêàöèÿ: ïîèñê íåèíèöèàëèçèðîâàííûõ ïåðåìåííûõ public string Foo(string a, string b) { string min; int cmpResult = a.CompareTo(b); if (cmpResult < 0) min = a; if (cmpResult >= 0) min = b; return min; } Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 8 / 29
  • 15. Âåðèôèêàöèÿ: ïîèñê íåèíèöèàëèçèðîâàííûõ ïåðåìåííûõ public string Foo(string a, string b) { string min; int cmpResult = a.CompareTo(b); if (cmpResult < 0) // False min = a; if (cmpResult >= 0) // False min = b; return min; } Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 9 / 29
  • 16. "Âåðèôèêàöèÿ"â CodeContracts Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 10 / 29
  • 17. Ïðèìåð êîíòðàêòîâ public string Greet(string [] args) { Contract.Requires(args != null); Contract.Requires(args.Length > 0); Contract.Requires(args [0] != null); Contract.Ensures(Contract.Result <string >().Length > 5); Console.WriteLine("Hello , {0}!", args [0]); return "abacaba" + args [0]; } Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 11 / 29
  • 18. Roslyn: èñïîëüçóåì íà ïðàêòèêå Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 12 / 29
  • 19. Ïàðó ñëîâ î Roslyn Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 13 / 29
  • 20. Ïðàêòè÷åñêîå ïðèìåíåíèå Roslyn: áîðåìñÿ ñ boilerplate Entitas - The Entity Component System Framework for C# and Unity Çàäà÷à: àâòîìàòè÷åñêè ãåíåðèðîâàòü boilerplate êîä äëÿ ðàáîòû ñ êîìïîíåíòàìè. Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 14 / 29
  • 21. Ïðàêòè÷åñêîå ïðèìåíåíèå Roslyn: áîðåìñÿ ñ boilerplate Entitas - The Entity Component System Framework for C# and Unity Çàäà÷à: àâòîìàòè÷åñêè ãåíåðèðîâàòü boilerplate êîä äëÿ ðàáîòû ñ êîìïîíåíòàìè. public class PositionComponent : IComponent { public float X; public float Y; } Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 14 / 29
  • 22. Ïðàêòè÷åñêîå ïðèìåíåíèå Roslyn: áîðåìñÿ ñ boilerplate Entitas - The Entity Component System Framework for C# and Unity Çàäà÷à: àâòîìàòè÷åñêè ãåíåðèðîâàòü boilerplate êîä äëÿ ðàáîòû ñ êîìïîíåíòàìè. public class PositionComponent : IComponent { public float X; public float Y; } public void AddPosition(float newX , float newY) { var component = CreateComponent <PositionComponent > (BattleComponentsLookup.Position); component.X = newX; component.Y = newY; AddComponent(BattleComponentsLookup.Position , component); } Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 14 / 29
  • 23. Ãåíåðàöèÿ ÷åðåç Reection var types = Assembly .GetAssembly(typeof(MainClass)) .GetTypes (); foreach (var type in types) { Process(type); } Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 15 / 29
  • 24. Ãåíåðàöèÿ ÷åðåç Reection var types = Assembly .GetAssembly(typeof(MainClass)) .GetTypes (); foreach (var type in types) { Process(type); } Ãëàâíàÿ ïðîáëåìà: ãåíåðàöèÿ ðàáîòàåò òîëüêî åñëè ïðîåêò êîìïèëèðóåòñÿ. Åñëè âû õîòèòå ðåôàêòîðèòü, íóæíî èñïðàâëÿòü âñå îøèáêè â ñãåíåðèðîâàííîì êîäå. Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 15 / 29
  • 25. Ãåíåðàöèÿ ÷åðåç Roslyn using (var workspace = MSBuildWorkspace.Create ()) { var solution = workspace.OpenSolutionAsync(path).Result; foreach (var project in solution.Projects){ var compilation = project.GetCompilationAsync ().Result; var allTypes = compilation.GetSymbolsWithName(x = true , SymbolFilter.Type).OfType ITypeSymbol (); foreach (var type in types) Process(type) } } Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 16 / 29
  • 26. Èñêëþ÷åíèå íà Mac/Mono Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded. at (wrapper managed -to-native) System.Reflection.Assembly:GetTypes (System.Reflection.Assembly ,bool) at System.Reflection.Assembly.GetTypes () [0 x00000] in 8f2c484307284b51944a1a13a14c0266 :0 at System.Reflection.Assembly+c__Iterator0.MoveNext () [0 x00021] in 8f2c484307284b51944a1a13a14c0266 :0 at System.Linq.Enumerable+WhereSelectEnumerableIterator `2[ TSource ,TResult ]. MoveNext () [0 x00078] in 63992662 b765477a898ef49cdcc99ee2 :0 at System.Linq.Enumerable+SelectManyIterator c__Iterator2 `2[ TSource ,TResult ]. MoveNext () [0 x000bc] in 63992662 b765477a898ef49cdcc99ee2 :0 at System.Composition.TypedParts.TypedPartExportDescriptorProvider ..ctor (System.Collections.Generic.IEnumerable `1[T] types , System.Composition.Convention.AttributedModelProvider attributeContext) [0 x00049] in c091afde214c4b8e8efbbeb9d44062d4 :0 at System.Composition.Hosting.ContainerConfiguration.CreateContainer () [0 x00042] in c091afde214c4b8e8efbbeb9d44062d4 :0 at Microsoft.CodeAnalysis.Host.Mef.MefHostServices.Create (System.Collections.Generic.IEnumerable `1[T] assemblies) [0 x00019] in 947408 acdcbc4eba93cdb6a19d92fcd1 :0 at Microsoft.CodeAnalysis.Host.Mef.DesktopMefHostServices.get_DefaultServices () [0 x00011] in 2ba3a08d4fe0467c8c54c8bc37c61987 :0 at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.Create (System.Collections.Generic.IDictionary `2[TKey ,TValue] properties) [0 x00000] in 2ba3a08d4fe0467c8c54c8bc37c61987 :0 at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.Create () [0 x00000] in 2ba3a08d4fe0467c8c54c8bc37c61987 :0 ... Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 17 / 29
  • 27. Ñòàòè÷åñêèé àíàëèç Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 18 / 29
  • 28. Çà÷åì ðàçðàáîò÷èêàì íóæåí ñòàòè÷åñêèé àíàëèç Ñòàòè÷åñêèé àíàëèç èñïîëüçóåòñÿ êàê äëÿ ïîèñêà îøèáîê äî òåñòèðîâàíèÿ, òàê è äëÿ ïîèñêà îøèáîê, ïðîïóùåííûõ ïðè òåñòèðîâàíèè Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 19 / 29
  • 29. Çà÷åì ðàçðàáîò÷èêàì íóæåí ñòàòè÷åñêèé àíàëèç Ñòàòè÷åñêèé àíàëèç èñïîëüçóåòñÿ êàê äëÿ ïîèñêà îøèáîê äî òåñòèðîâàíèÿ, òàê è äëÿ ïîèñêà îøèáîê, ïðîïóùåííûõ ïðè òåñòèðîâàíèè ×åì áîëüøå ðàçìåð êîìàíäû, òåì ýôôåêòèâíåå ðàáîòàåò ñòàòè÷åñêèé àíàëèç Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 19 / 29
  • 30. Çà÷åì ðàçðàáîò÷èêàì íóæåí ñòàòè÷åñêèé àíàëèç Ñòàòè÷åñêèé àíàëèç èñïîëüçóåòñÿ êàê äëÿ ïîèñêà îøèáîê äî òåñòèðîâàíèÿ, òàê è äëÿ ïîèñêà îøèáîê, ïðîïóùåííûõ ïðè òåñòèðîâàíèè ×åì áîëüøå ðàçìåð êîìàíäû, òåì ýôôåêòèâíåå ðàáîòàåò ñòàòè÷åñêèé àíàëèç Ïðèìåíåíèå ñëîæíîãî ñòàòè÷åñêîãî àíàëèçà ïðåäïîëàãàåò âûñîêóþ öåíó îøèáêè Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 19 / 29
  • 31. Çà÷åì ðàçðàáîò÷èêàì íóæåí ñòàòè÷åñêèé àíàëèç Ñòàòè÷åñêèé àíàëèç èñïîëüçóåòñÿ êàê äëÿ ïîèñêà îøèáîê äî òåñòèðîâàíèÿ, òàê è äëÿ ïîèñêà îøèáîê, ïðîïóùåííûõ ïðè òåñòèðîâàíèè ×åì áîëüøå ðàçìåð êîìàíäû, òåì ýôôåêòèâíåå ðàáîòàåò ñòàòè÷åñêèé àíàëèç Ïðèìåíåíèå ñëîæíîãî ñòàòè÷åñêîãî àíàëèçà ïðåäïîëàãàåò âûñîêóþ öåíó îøèáêè Ñòàòè÷åñêèé àíàëèç õîðîøî ñî÷åòàåòñÿ ñ CodeReview Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 19 / 29
  • 32. Òðåáîâàíèÿ ê ñòàòè÷åñêèì àíàëèçàòîðàì Âðåìÿ ðàáîòû Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 20 / 29
  • 33. Òðåáîâàíèÿ ê ñòàòè÷åñêèì àíàëèçàòîðàì Âðåìÿ ðàáîòû Ñîîòíîøåíèå âûäàíî ïðåäóïðåæäåíèé/âíåñåíî èñïðàâëåíèé Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 20 / 29
  • 34. Òðåáîâàíèÿ ê ñòàòè÷åñêèì àíàëèçàòîðàì Âðåìÿ ðàáîòû Ñîîòíîøåíèå âûäàíî ïðåäóïðåæäåíèé/âíåñåíî èñïðàâëåíèé Ïîääåðæèâàåìûå êëàññû îøèáîê, âêëþ÷àÿ ïîäêëàññû Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 20 / 29
  • 35. Òðåáîâàíèÿ ê ñòàòè÷åñêèì àíàëèçàòîðàì Âðåìÿ ðàáîòû Ñîîòíîøåíèå âûäàíî ïðåäóïðåæäåíèé/âíåñåíî èñïðàâëåíèé Ïîääåðæèâàåìûå êëàññû îøèáîê, âêëþ÷àÿ ïîäêëàññû Ïîíÿòíîñòü ñîîáùåíèé îá îøèáêàõ Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 20 / 29
  • 36. Òðåáîâàíèÿ ê ñòàòè÷åñêèì àíàëèçàòîðàì Âðåìÿ ðàáîòû Ñîîòíîøåíèå âûäàíî ïðåäóïðåæäåíèé/âíåñåíî èñïðàâëåíèé Ïîääåðæèâàåìûå êëàññû îøèáîê, âêëþ÷àÿ ïîäêëàññû Ïîíÿòíîñòü ñîîáùåíèé îá îøèáêàõ Èíòåãðàöèÿ ñ CI Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 20 / 29
  • 37. Èíñòðóìåíòû ñòàòè÷åñêîãî àíàëèçà Coverity SharpChecker (íàø èíñòðóìåíò) SonarLint ReSharper PVS-Studio Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 21 / 29
  • 38. Coverity Äå ôàêòî ñòàíäàðò êà÷åñòâà äëÿ èíñòðóìåíòîâ ñòàòè÷åñêîãî àíàëèçà Ïðîäàåòñÿ òîëüêî çà áîëüøèå äåíüãè Áåñïëàòåí äëÿ OpenSource íà https://scan.coverity.com Âñå âèäû àíàëèçà: AST, âíóòðèïðîöåäðóíûé, ìåæïðîöåäóðûíé Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 22 / 29
  • 39. SharpChecker Ñòàòè÷åñêèé àíàëèç íà îñíîâå Roslyn, ðàçðàáîòàííûé â ÈÑÏ ÐÀÍ. Öåëü ïðîåêòà: ðàçðàáîòàòü èíñòðóìåíò, ñîîòâåòñòâóþùèé óðîâíþ ëó÷øèõ ñîâðåìåííûõ ñòàòè÷åñêèõ àíàëèçàòîðîâ. Âñå âèäû àíàëèçà: AST, âíóòðèïðîöåäðóíûé, ìåæïðîöåäóðûíé. http://sharpchecker.ispras.ru Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 23 / 29
  • 40. SonarLint for VisualStudio Áåñïëàòíàÿ êîëëåêöèÿ àíàëèçàòîðîâ äëÿ Roslyn Èíòåãðàöèÿ ñ SonarQube Èíòåãðàöèÿ ñ ñáîðêîé msbuild Áîëåå 100 AST àíàëèçàòîðîâ Èíòåãðàöèÿ ñ Visual Studio Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 24 / 29
  • 41. Ñðàâíåíèå ReSharper è PVS-Studio ReSharper PVS-Studio Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 25 / 29
  • 42. Ñðàâíåíèå ReSharper è PVS-Studio ReSharper PVS-Studio Êîëè÷åñòâî ñòàòåé íà õàðáðàõàáðå çà ôåâðàëü 0 8 Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 25 / 29
  • 43. Ñðàâíåíèå ReSharper è PVS-Studio ReSharper PVS-Studio Êîëè÷åñòâî ñòàòåé íà õàðáðàõàáðå çà ôåâðàëü 0 8 Íàëè÷èå AST-äåòåêòîðîâ Äà Äà Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 25 / 29
  • 44. Ñðàâíåíèå ReSharper è PVS-Studio ReSharper PVS-Studio Êîëè÷åñòâî ñòàòåé íà õàðáðàõàáðå çà ôåâðàëü 0 8 Íàëè÷èå AST-äåòåêòîðîâ Äà Äà Íàëè÷èå âíóòðèïðîöåäóðíîãî àíàëèçà ïîòîêîâ äàííûõ Äà Íåò Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 25 / 29
  • 45. Ñðàâíåíèå ReSharper è PVS-Studio ReSharper PVS-Studio Êîëè÷åñòâî ñòàòåé íà õàðáðàõàáðå çà ôåâðàëü 0 8 Íàëè÷èå AST-äåòåêòîðîâ Äà Äà Íàëè÷èå âíóòðèïðîöåäóðíîãî àíàëèçà ïîòîêîâ äàííûõ Äà Íåò Àíàëèç âî âðåìÿ ðàçðàáîòêè Äà Íåò Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 25 / 29
  • 46. Ñðàâíåíèå ReSharper è PVS-Studio ReSharper PVS-Studio Êîëè÷åñòâî ñòàòåé íà õàðáðàõàáðå çà ôåâðàëü 0 8 Íàëè÷èå AST-äåòåêòîðîâ Äà Äà Íàëè÷èå âíóòðèïðîöåäóðíîãî àíàëèçà ïîòîêîâ äàííûõ Äà Íåò Àíàëèç âî âðåìÿ ðàçðàáîòêè Äà Íåò Èíòåãðàöèÿ ñ CI Äà Äà Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 25 / 29
  • 47. Ñðàâíåíèå ReSharper è PVS-Studio ReSharper PVS-Studio Êîëè÷åñòâî ñòàòåé íà õàðáðàõàáðå çà ôåâðàëü 0 8 Íàëè÷èå AST-äåòåêòîðîâ Äà Äà Íàëè÷èå âíóòðèïðîöåäóðíîãî àíàëèçà ïîòîêîâ äàííûõ Äà Íåò Àíàëèç âî âðåìÿ ðàçðàáîòêè Äà Íåò Èíòåãðàöèÿ ñ CI Äà Äà Õîðîøàÿ äîêóìåíòàöèÿ Íåò Äà Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 25 / 29
  • 48. Äèíàìè÷åñêèé àíàëèç Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 26 / 29
  • 49. PEX / IntelliTest http://www.pexforfun.com/ Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 27 / 29
  • 50. Èäåÿ ðàáîòû IntelliTest Àëãîðèòì ðàáîòû: çàïóñòèì ìåòîä ñ êàêèìè-íèáóäü ïàðàìåòðàìè; Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 28 / 29
  • 51. Èäåÿ ðàáîòû IntelliTest Àëãîðèòì ðàáîòû: çàïóñòèì ìåòîä ñ êàêèìè-íèáóäü ïàðàìåòðàìè; ïîñòðîèì ôîðìóëó, êîòîðàÿ îïèñûâàåò åãî âûïîëíåíèå; Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 28 / 29
  • 52. Èäåÿ ðàáîòû IntelliTest Àëãîðèòì ðàáîòû: çàïóñòèì ìåòîä ñ êàêèìè-íèáóäü ïàðàìåòðàìè; ïîñòðîèì ôîðìóëó, êîòîðàÿ îïèñûâàåò åãî âûïîëíåíèå; ðåøèì çàäà÷ó: êàêèìè äîëæíû áûòü ïàðàìåòðû, ÷òîáû âûïîëíåíèå ïðîøëî ïî äðóãîé âåòêå è óâåëè÷èëî ïîêðûòèå; Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 28 / 29
  • 53. Èäåÿ ðàáîòû IntelliTest Àëãîðèòì ðàáîòû: çàïóñòèì ìåòîä ñ êàêèìè-íèáóäü ïàðàìåòðàìè; ïîñòðîèì ôîðìóëó, êîòîðàÿ îïèñûâàåò åãî âûïîëíåíèå; ðåøèì çàäà÷ó: êàêèìè äîëæíû áûòü ïàðàìåòðû, ÷òîáû âûïîëíåíèå ïðîøëî ïî äðóãîé âåòêå è óâåëè÷èëî ïîêðûòèå; çàïóñòèì ñ íîâûìè äàííûìè. Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 28 / 29
  • 54. Ñïàñèáî çà âíèìàíèå! Âëàäèìèð Êîøåëåâ vedun@ispras.ru Ññûëêè: SharpChecker: http://sharpchecker.ispras.ru Coverity: https://scan.coverity.com SonarLint : http://www.sonarlint.org/visualstudio/ Âëàäèìèð Êîøåëåâ (ÈÑÏ ÐÀÍ) Àâòîìàòè÷åñêèé ïîèñê îøèáîê 21 ôåâðàëÿ 2017 ã. 29 / 29