Pour ceux qui ne le saurait pas, nous (Gat, Seb, Adrien, Julien et Moi) avons mis à disposition une sorte de mini Framework pour simplifier le développement sur SharePoint et l'avons mis à disposition sur Codeplex sous le nom de projet SharePointOfView. Grosso modo, on en est plutôt content car :
- Fabrice en parle dans ses articles (merci au passage)
- Renaud visite notre site, nous signale des bugs et veut mettre la main à la patte (cf dernier checkin :)
- Seb se découvre un gout pour le cinéma (presque) dans ces posts :)
Bref que du bonheur.
Mais histoire de me plomber le moral, je me suis demandé ce qui se passerait si je lancai NDepend (l'outil de Patrick Smacchia) sur SharePointOfView... C'est parti.
On commence par la base :
Voilà une petite réprésentation du contenu des deux DLL de SharePointOfView.
et quelques Infos supplémentaires
Application Metrics |
Assemblies Dependencies Diagram |
- Number of IL instructions: 2891
- Number of lines of code: 478
- Number of lines of comment: 310
- Percentage comment: 39%
- Number of assemblies: 2
- Number of classes: 20
- Number of types: 27
- Number of abstract classes: 2
- ...
- Percentage of public types: 59.26%
- Percentage of public methods: 62.79%
|

|
Sympa ! Ca fait plaisir de voir du code commenté pour une fois :)
Mais la requête suivante me fait moins plaisir :(
// <Name>Quick summary of methods to refactor</Name>
WARN IF Count > 0 IN SELECT TOP 10 METHODS /*OUT OF "YourGeneratedCode" */ WHERE
// Metrics' definitions
( NbLinesOfCode > 30 OR // http://www.ndepend.com/Metrics.aspx#NbLinesOfCode
NbILInstructions > 200 OR // http://www.ndepend.com/Metrics.aspx#NbILInstructions
CyclomaticComplexity > 20 OR // http://www.ndepend.com/Metrics.aspx#CC
ILCyclomaticComplexity > 50 OR // http://www.ndepend.com/Metrics.aspx#ILCC
ILNestingDepth > 4 OR // http://www.ndepend.com/Metrics.aspx#ILNestingDepth
NbParameters > 5 OR // http://www.ndepend.com/Metrics.aspx#NbParameters
NbVariables > 8 OR // http://www.ndepend.com/Metrics.aspx#NbVariables
NbOverloads > 6 ) // http://www.ndepend.com/Metrics.aspx#NbOverloads
AND
// Here are some ways to avoid taking account of generated methods.
!( NameIs "InitializeComponent()" OR
// NDepend.CQL.GeneratedAttribute is defined in the redistributable assembly $NDependInstallDir$\Lib\NDepend.CQL.dll
// You can define your own attribute to mark "Generated".
HasAttribute "OPTIONAL:NDepend.CQL.GeneratedAttribute")
Résultat (épuré):
- SovDeleteItems :SharePointOfView.ExtensionMethods.List.SovDeleteItems(SPList,Boolean,Dictionary<String,String>)
- SovAddItems : SharePointOfView.ExtensionMethods.List.SovAddItems(SPList,Int32,Dictionary<String,String>,Boolean)
- SovDeleteUploadedFiles : SharePointOfView.ExtensionMethods.FeatureReceiverProperties.SovDeleteUploadedFiles(SPFeatureReceiverProperties)
- RenderWebPart(HtmlTextWriter) : SharePointOfView.WebControls.XslTransformWebPart.RenderWebPart(HtmlTextWriter)
- FeatureActivated : SharePointOfView.EventReceivers.WebConfigFeatureReceiver.FeatureActivated(SPFeatureReceiverProperties)
Les trois premières méthodes ayant été codées par moi... Damned !
SovDeleteUploadedFiles et FeatureActivated sont aussi les methodes listées par les requêtes suivantes :
// <Name>Methods too big (NbLinesOfCode)</Name>
WARN IF Count > 0 IN SELECT TOP 10 METHODS WHERE NbLinesOfCode > 30 ORDER BY NbLinesOfCode DESC
// METHODS WHERE NbLinesOfCode > 30 are extremely complex and
// should be split in smaller methods
// (except if they are automatically generated by a tool).
// See the definition of the NbLinesOfCode metric here http://www.ndepend.com/Metrics.aspx#NbLinesOfCode
// <Name>Methods too big (NbILInstructions)</Name>
WARN IF Count > 0 IN SELECT TOP 10 METHODS WHERE NbILInstructions > 200 ORDER BY NbILInstructions DESC
// METHODS WHERE NbILInstructions > 200 are extremely complex and
// should be split in smaller methods
// (except if they are automatically generated by a tool).
// See the definition of the NbILInstructions metric here http://www.ndepend.com/Metrics.aspx#NbILInstructions
// <Name>Methods too complex (ILNestingDepth)</Name>
WARN IF Count > 0 IN SELECT TOP 10 METHODS WHERE ILNestingDepth > 4 ORDER BY ILNestingDepth DESC
// METHODS WHERE ILNestingDepth > 4 are hard to understand and maintain.
// METHODS WHERE ILNestingDepth > 8 is higher than 8 are extremely complex and should be split in smaller methods
// (except if they are automatically generated by a tool).
// See the definition of the NbILInstructions metric here http://www.NDepend.com/Metrics.aspx#ILNestingDepth
Bref, vous l'aurez compris, l' outil de Patrick m'a permis de me relancer dans l'évolution de notre petit "bébé" en continuant à l'améliorer et à l'optimizer.
Bien sur, cet outil ne se limite qu'à ce genre de requêtes voire même de rapport, on peut aller bien plus loin.
Je vous encourage vivement à aller visiter le site et les démos pour vous donner une idée plus complète.
<Philippe/>