Riting Roslyn Refactorings Harnessing The Compiler As A Service

Riting Roslyn Refactorings Harnessing The Compiler As A Service

Assessing Code Quality and Technical Debt Using SonarQube Guy Smith-Ferrier [email protected] http://www.guysmithferrier.com About Author of .NET Internationalization o Visit http://www.dotneti18n.com to

download the complete source code Author of NCLDR o http://www.ncldr.com o An open source .NET implementation of CLDR Agenda

Introduction to SonarQube Demo: Installing SonarQube Demo: C# Analysis using SonarQube Rule Repositories o SonarQube, StyleCop, FxCop, Refactoring Essentials, Code Cracker, ReSharper, NDepend, Wintellect

Duplicate Rules Holy Wars Analyzing Unit Test Projects Code Quality Erosion SonarQube An open source project since 2006 SonarSource formed in 2008

o Based on Switzerland o 60+ employees (2017) o First commercial plugin in 2009 700,000 downloads, 140,000 downloads in 2016 80,000 organisations use SonarQube o 800+ customers o 7 customers in Fortune 10 o 47 customers in Fortune 100 60+ open source plugins

SonarQube Language Support Actively developed o Java, C#, JavaScript, COBOL, C/C++ Developed according to demand o PL/SQL, PHP, ABAP, VB.NET, Python, RPG, Flex, Objective-C, Swift, Web, CSS, Erlang, Groovy, Lua, Puppet Planned for 2017?

o TypeScript, T-SQL Third Party o Clojure, F#, Perl, Ruby Demo Suppressing Rules 1. SuppressMessage attribute o Works in Visual Studio and on the Build Server o Includes an optional Justification parameter

2. #pragma o Works in Visual Studio and on the Build Server o No Justification parameter o Not easily trackable 3. SonarQube suppressions o Has no effect in Visual Studio 4. ReSharper disable comments o Only affect ReSharper

SonarQube C# Rules 238 rules Implemented in Roslyn Rule Help is excellent 6 common (server-side only) rules

(Roslyn) StyleCop 187 rules Implemented in Roslyn Rule Help is excellent Classic FxCop 233 rules Implemented in Code Analysis in Visual Studio o Errors/warnings appear in Visual Studios Error List window o Rules only show in a clean build

o SonarLint deletes all non-Roslyn rules from rulesets Implemented in FxCopCmd.exe on the Build Server o Requires Visual Studio to be installed on the server FxCop does not always respect SuppressMessages that include a scope High degree of overlap with SonarQube ruleset Roslyn FxCop

140 rules o Not all rules ported (e.g. CAS) Implemented in Roslyn o Match the version of the analyser to the version of Microsoft.CodeAnalysis supported by Visual Studio Visual Studio 2013: Not supported Visual Studio 2015: Microsoft.CodeAnalysis 1.2 Visual Studio 2017:

Microsoft.CodeAnalysis 2.2 Spread over 6 NuGet packages Refactoring Essentials 168 rules Implemented in Roslyn Rule Help is poor Code Cracker 76 rules

Implemented in Roslyn Rule Help is poor ReSharper 675 rules Implemented in ReSharper o Errors / warnings appear in ReSharpers dedicated window Implemented in InspectCode.exe on the Build Server o A free download (see ReSharper Command Line Tools)

Rule Help is good The SonarSource Plugin is no longer available o Download Greg Bartletts replacement from:o https://github.com/GregBartlett/sonar-resharper Wintellect Analyzers

14 rules Implemented in Roslyn Rule Help is good Some rules are counted as errors o The build breaks (even if these rules are disabled) NDepend 145 rules Implemented in NDepend o Errors / warnings appear in NDepends dedicated window

Implemented in NDepends runner on the Build Server o Requires a separate NDepend Build Server licence Rule Help is available through the NDepend project file Rules cannot be suppressed (yet) Duplicate Rules .NET Ruleset

Inspector https://github.com/GuySmithFerrier/ RulesetInspector My Favourite Holy Wars

1. 2. 3. 4. 5. var vs. Explicit Types this vs. not this Tabs vs. spaces XML code comments

Ketchup: in the cupboard or in the fridge? Analyzing Unit Test Projects To analyse or not to analyse? o Its not production code o It *is* an asset of the company Analyse but use a reduced ruleset o via a standard set of suppressions o by disabling rules according to their file path

Code Quality Erosion Rule Count Bad Time Code Quality Erosion

Rule Count Good Time Information Sources Twitter o @SonarSource, @SonarQube, @SonarLint Newsletters

o http://www.sonarsource.com/resources/product-news o http://www.sonarsource.com/resources/newsletter Support o SonarQube Google Groups Bug Tracking and Development o http://jira.sonarsource.com Summary SonarQube analyses Code Quality and assesses

Technical Debt SonarQube exposes statistical data to all stakeholders (not just developers) SonarQube tracks metrics over time At least half of the effort spent on SonarQube Administration centres on the socialisation of Code Quality Its More Readable There is no such thing as empirically more readable

More readable only applies to individuals Code is more readable if it looks like what you are used to reading

Recently Viewed Presentations

  • Cell Review - local-brookings.k12.sd.us

    Cell Review - local-brookings.k12.sd.us

    Cell Communication. Direct contact - molecules on the surface of one cell are recognized by receptors on the adjacent cell. Cell Communication. Paracrine signaling - signal released from a cell has an effect on neighboring cells. ... Cell Review Last...
  • Differentiating Bacterial and Viral Sepsis in the Newborn

    Differentiating Bacterial and Viral Sepsis in the Newborn

    Infants of obese mothers may require supplementation banked human milk feeding or formula until the mother's breast milk is enough to meet the infant's nutritional requirements Jorgensen AM NICU Currents June 2010 volume1, Issue 1.
  • Diagnostic Approach and Overview of Pancytopenias

    Diagnostic Approach and Overview of Pancytopenias

    Bone marrow aplasia. B12/folate deficiency, medications (e.g. methotrexate, cyclophosphamide, colchicine, azathioprine, ganciclovir, etc.), immune destruction, aplastic anemia, infection (HIV, viral hepatitis, parvovirus B19) ... can do bone marrow biopsy if still required, but should wait 1-2 ...
  • Apostrophes - images.pcmac.org

    Apostrophes - images.pcmac.org

    Complex Apostrophes. If the two people or things that own something are combined with "and" only one apostrophe is needed Tom and Jane's car is green.. If the two people or things that own something are combined with "or" then...
  • Michelle Obamas Speech at the 2012 Democratic National

    Michelle Obamas Speech at the 2012 Democratic National

    : The "new" conversation casts Obama in a better light than Romney. If the RNC message was that "times are bad, and Obama hasn't made them any better, so we need a change of leadership," Michelle's goal to is change...
  • Afternoons by Phillip Larkin. What does time mean

    Afternoons by Phillip Larkin. What does time mean

    Summer is fading:The leaves fall in ones and twosFrom trees borderingThe new recreation ground.In the hollows of afternoonsYoung mothers assembleAt swing and sandpitSetting free their children.Behind them, at intervals,Stand husbands in skilled trades,An estateful of washing,And the albums, lettered
  • What is geography?

    What is geography?

    Soil components Soil formation Classifying soils: color Classifying soils: texture Classifying soils: texture Classifying soils: structure Classifying soils: structure Soil moisture Soil-water balance Soil profiles Soil classification Entisols Oxisols Aridisols Mollisols Alfisols Spodosols Soil degradation Soil degradation Soil degradation
  • INCIVILITY Training for Nursing Faculty to Foster Teamwork

    INCIVILITY Training for Nursing Faculty to Foster Teamwork

    Any action that is rude, discourteous, offensive, intimidating, or hostile that interferes with the learning and/or practice environment. Evidence suggests that incivility on American college campuses, ranging from insulting remarks and verbal abuse to violence, is a serious and growing...