This presentation was held at SPC Adriatics 2014 in Zagreb 10/15/2014
http://spcadriatics.com/2014/session/assuring-the-code-quality-of-sharepoint-solutions-and-apps/
Abstract
SharePoint development and fun do not always have much in common!
Everyone who has ever developed for SharePoint might know what I mean. Even a small SharePoint solution or app consist already of a large number of different files (xml, cs, js, css, resx, jpg, aspx, etc.) which may be implemented and structured differently in every project.
Especially with the shift of the development approach to the new App model, SharePoint veterans but also rookies find themselves confronted with many new technologies, frameworks, and coding practices.
As a result the quality and maintainability of SharePoint solutions and apps differs very much depending on the experience and preference of the individual developers.
In this session we will discuss the common challenges in SharePoint development, as well as the possibilities to standardize the development approach in the team and automatically assure these policies and practices.
[2024]Digital Global Overview Report 2024 Meltwater.pdf
Â
Assuring the Code Quality of SharePoint Solutions and Apps
1. Assuring the Code Quality of SharePoint Solutions and Apps
Matthias Einig, MVPRENCORE AB
2.
3. Who is that guy?
matthias.einig@rencore.se
www.matthiaseinig.de
Matthias Einig
CEO, SharePoint MVP
Stockholm, Sweden
4. What is Code Quality?
Source: Consortium for IT Software Quality
â˘Reliability
â˘Security
â˘Efficiency
â˘Maintainability
â˘Size
5. Why should we care?
â˘Avoid bugs
â˘Reduce effort (coding & testing)
â˘Improve maintainability
â˘Prepare for changes/upgrade
â˘Increase team flexibility
Code Quality canât be easily added later!
6.
7. How to measure Code Quality?
â˘Architectural standards
â˘Coding Practices
â˘Complexity
â˘Documentation
â˘Portability
â˘Tech./Func. Volume
Reliability
Security
Efficiency
Maintainability
Size
8. How to analyse Code Quality?
â˘Static vs. Dynamic
â˘Source Code vs. Object Code
â˘Manual vs. Automated
â˘Ad hoc vs. Continuously
9. Why is it important for SharePoint?
â˘Solutions / apps are black boxes
â˘Code quality differs a lot
â˘Solutions change (ALM)
â˘Complexity
â˘Policies / Best Practices
â˘Dev Teams Change
â˘Farm stability / security / licensing
10. So, what is SharePoint Code?
ď.NET code
ďXML: Manifest, Features, Content Types, Templates
ďHTML, ASPX, ASCX
ďCSS, JavaScript
ďImages, resources, document templatesâŚ
ďDeployment locations!
11. Is my code
correctand followsbest practices?
Developer
Is the codewelldesignedand maintainable?
Architect
Does the codecomplywithcompanypoliciesand standards?
Quality Manager
Who needs it and why?
Will the code
harm my farm?
Administrator
12. What Tools do we have?`
ObjectCodeFxCop/VSCA
FxCop Metrics
CAT.net
SourceCode StyleCop
SPCode SPDisposeCheck
MSOCAF
Checks against general coding errors (not SharePoint-specific)
Calculates code metrics (only.NET code, not SharePoint specific)
Checks codingstyle guidelines(only .NET code, not SharePoint specific)
Analyzescode security
(not SharePoint-specific)
Checks memory leaks
(SharePoint-specific)
Combination of FxCop and SPDisposeCheck for SharePoint Online
13. The GapâŚ
Whatâsmissing?
â˘Analyze SharePoint specific code quality!
â˘Analyze SharePoint dependencies!
â˘Gather SharePoint metrics!
â˘Documentthe SharePoint solution / app!
â˘Assess the migratabilityto the app model!
18. ďUse predefined rulesetse.g. SP2013 Compatibility
ďCreate your own ruleset
ďEnable/disable rules
ďAdjust severity of notifications
ďInformation
ďWarning
ďError
Configure Rulesets
19. Run SPCAF in TeamBuildas Quality Gate
â˘Custom Build Activity
â˘Supports TFS 2010/2012/2013, VS Online, Team City etc.
Build in TFS on-premises
Build in Visual Studio Online
Continuous Integration
22. 5.Add RuleMetadatanamespaceSP24.Rules{ [RuleMetadata(typeof(Naming), CheckId= "SPC99001", DisplayName= "Feature name should start with SP24", Description = "A feature name should be prefixed with 'SP24'.", DefaultSeverity= Severity.Warning, SharePointVersion= newstring[] { "12", "14", "15"}, Message = "Feature '{0}' should start with 'SP24'.", Resolution = "Change the folder name of the feature and add the name at the beginning, e.g.âSP24.Intranet.Components.ContentTypesFeature'.")] publicclassFeatureNameStartsWithSP24: Rule<FeatureDefinition> { ...
Youwantto ruleyourself? (2)
23. 7.Build and drop the assembly into the SPCAF installation folderpublicclassFeatureNameStartsWithSP24: Rule<FeatureDefinition> { publicoverridevoidVisit(FeatureDefinitiontarget, NotificationCollectionnotifications) { if(!target.FeatureName.StartsWith("SP24")) { stringmessage = string.Format(this.MessageTemplate(), target.FeatureName); Notify(target, message, notifications); } } }
6.Implement the rule
Youwantto ruleyourself? (3)
24. Summary
â˘Code Quality must notbe a fluke!
â˘Helps you to find problems earlier
â˘Saves yourtime & money
â˘Prepares you for changes and upgrades
â˘QA can be implemented in several steps
Also check out my session:
SharePoint Continuous Integration with VS Online and Azure
D2S3DEV 10/16/201411:30 AM