Investigating the Applicability of Software Metrics and Technical Debt on X++ Abstract Syntax Tree in XML Format – Calculations Using Xquery Expressions
Total Page:16
File Type:pdf, Size:1020Kb
Linköping University | Department of Computer and Information Science Master’s thesis, 30 ECTS | Datateknik 202019 | LIU-IDA/LITH-EX-A--2019/101--SE Investigating the applicability of Software Metrics and Technical Debt on X++ Abstract Syntax Tree in XML format – calculations using XQuery expressions Tillämpning av mjukvarumetri och tekniska skulder från en XML representation av abstrakta syntaxträd för X++ kodprogram David Tran Supervisor : Jonas Wallgren Examiner : Martin Sjölund External supervisor : Laurent Ricci Linköpings universitet SE–581 83 Linköping +46 13 28 10 00 , www.liu.se Upphovsrätt Detta dokument hålls tillgängligt på Internet ‐ eller dess framtida ersättare ‐ under 25 år frånpublicer‐ ingsdatum under förutsättning att inga extraordinära omständigheter uppstår. Tillgång till dokumentet innebär tillstånd för var och en att läsa, ladda ner, skriva ut enstakako‐ pior för enskilt bruk och att använda det oförändrat för ickekommersiell forskning och för undervis‐ ning. Överföring av upphovsrätten vid en senare tidpunkt kan inte upphäva detta tillstånd. Allannan användning av dokumentet kräver upphovsmannens medgivande. För att garantera äktheten, säker‐ heten och tillgängligheten finns lösningar av teknisk och administrativ art. Upphovsmannens ideella rätt innefattar rätt att bli nämnd som upphovsman i den omfattning som god sed kräver vid användning av dokumentet på ovan beskrivna sätt samt skydd mot att dokumentet ändras eller presenteras i sådan form eller i sådant sammanhang som är kränkande för upphovsman‐ nens litterära eller konstnärliga anseende eller egenart. För ytterligare information om Linköping University Electronic Press se förlagets hemsida http://www.ep.liu.se/. Copyright The publishers will keep this document online on the Internet ‐ or its possible replacement ‐ for a period of 25 years starting from the date of publication barring exceptional circumstances. The online availability of the document implies permanent permission for anyone to read, to down‐ load, or to print out single copies for his/hers own use and to use it unchanged for non‐commercial research and educational purpose. Subsequent transfers of copyright cannot revoke this permission. All other uses of the document are conditional upon the consent of the copyright owner. The publisher has taken technical and administrative measures to assure authenticity, security and accessibility. According to intellectual property law the author has the right to be mentioned when his/her work is accessed as described above and to be protected against infringement. For additional information about the Linköping University Electronic Press and its procedures for publication and for assurance of document integrity, please refer to its www homepage: http://www.ep.liu.se/. © David Tran Abstract This thesis investigates how XML representation of X++ abstract syntax trees (AST) residing in an XML database can be subject to static code analysis. Microsoft Dynamics 365 for Finance & Operations comprises a large and complex corpus of X++ source code and intuitive ways of visualizing and analysing the state of the code base in terms of software metrics and technical debt are non-existent. A solution is to extend an internal web application and semantic search tool called SocrateX, to calculate software metrics and technical debt. This is done by creating a web service to construct XQuery and XPath code to be queried to the XML database. The values are stored in a relational database and imported to Power BI for intuitive visualization. Software metrics have been chosen based on the amount of previous research and compatibility with the X++ AST, whereas technical debt has been estimated using the SQALE method. This thesis concludes that XML representations of X++ abstract syntax trees are viable candidates for measuring quality of source codes with the use of functional query programming languages. Acknowledgments First and foremost, all work for this thesis has been carried out at Microsoft Development Center in Copenhagen. I would like to thank Laurent Ricci for being my mentor and giving me the opportunity to conduct my thesis at Microsoft. Secondly, I would like to thank my supervisor Jonas Wallgren for his indispensable help and feedback throughout writing this thesis and to Martin Sjölund for being my examiner. My friends in Norrköping, you know who you are. Thank you for making the five years of studying fly by in the blink of an eye. Thank you, Tobias Matts, for being my opponent in this thesis and for giving me valuable feedback on my report. I would also like to express my deepest gratitude to my family: Minh Tran, Phuong Nguyen and Amanda Tran, for their unconditional love and support throughout my five years’ time at Linköping University. Without them, I would not have this opportunity. Lastly, I want to thank Tu Do for being my rock during this thesis. There are no words that can express how much your encouragement, love and support have meant to me. v Contents Abstract iii Acknowledgments v Contents vii List of Figures ix List of Tables xi 1 Introduction 1 1.1 Motivation .......................................... 1 1.2 Aim .............................................. 2 1.3 Research questions ..................................... 2 1.4 Delimitations ........................................ 2 2 Background 5 2.1 Microsoft Development Center .............................. 5 2.1.1 Microsoft Dynamics 365 for Finance & Operations ............. 5 2.2 SocrateX ........................................... 5 3 Theory 7 3.1 Quality Assessment in Software Engineering ..................... 7 3.1.1 Software Development Life Cycle ........................ 7 3.1.2 Quality in Software ................................ 8 3.2 Trees ............................................. 10 3.3 Software metrics ...................................... 10 3.3.1 Traditional metrics ................................ 11 3.3.2 Chidamber & Kemerer Metric Suite ...................... 14 3.4 Technical Debt ....................................... 17 3.5 SQALE Method ...................................... 17 3.5.1 The SQALE Quality Model ........................... 18 3.5.2 The SQALE Analysis Model .......................... 21 3.5.3 The SQALE Indices ................................ 22 3.6 X++ Programming Language .............................. 22 3.6.1 Language Specific Restrictions ......................... 23 3.7 XML ............................................. 25 3.7.1 XPath ........................................ 26 3.7.2 XQuery ....................................... 29 3.8 XLNT Framework ..................................... 30 3.9 SocrateX ........................................... 30 3.9.1 ASP.NET Core .................................. 30 3.9.2 Angular Framework ................................ 30 vii 3.9.3 BaseX ........................................ 31 3.9.4 SocrateX Architecture .............................. 31 3.10 Entity Framework Core .................................. 32 3.11 Power BI ........................................... 33 3.12 Related Work ........................................ 33 4 Method 37 4.1 Approach .......................................... 37 4.1.1 Constructs in XML abstract syntax tree ................... 37 4.1.2 Applicability of software metrics ........................ 38 4.1.3 Applicability of technical debt ......................... 39 4.1.4 Integration with SocrateX ............................ 39 4.2 Implementation ....................................... 39 4.2.1 Traditional metrics ................................ 39 4.2.2 Chidamber & Kemerer Metric Suite ...................... 41 4.2.3 SQALE Method for Technical Debt ...................... 44 4.2.4 Web service - Static Code Analysis ....................... 46 4.2.5 Power BI ...................................... 52 4.2.6 Report Module in Angular ............................ 52 5 Results 55 5.1 Performance benchmark .................................. 55 5.2 Software metric values ................................... 55 5.3 Power BI Report ...................................... 56 5.3.1 Overview page ................................... 57 5.3.2 Artifact page .................................... 58 5.3.3 Software metric page ............................... 58 5.3.4 Rule page ...................................... 59 5.3.5 Team page ..................................... 59 6 Discussion 61 6.1 Results ............................................ 61 6.1.1 Database design and XQuery expressions ................... 61 6.1.2 XQuery performance ............................... 61 6.1.3 Software metrics .................................. 62 6.1.4 Technical Debt ................................... 64 6.1.5 Power BI Report .................................. 64 6.2 Method ............................................ 64 6.2.1 Validity ....................................... 65 6.2.2 Replicability .................................... 65 6.2.3 Reliability ...................................... 66 6.2.4 Source criticism .................................. 66 6.3 The work in a wider context ............................... 66 7 Conclusion 67 7.1 Consequences ........................................ 68 7.2 Future Work ........................................ 68 7.2.1 Historical data support .............................. 68 7.2.2 Task scheduler and Assembly in ASP.NET Core . 68 7.2.3 XQuery parallelism ................................ 68 7.2.4 Code refactoring .................................. 69