This project is aimed to create analysis reports of C# code using Abstract Syntax Trees created with SmaCC by John Brant. We aspire to detect code smells in C# Projects and help the developer fix them.
https://github.com/svenvc/ston
https://github.com/j-brant/SmaCC
https://github.com/zeroflag/Teapot
Initialize and parse a project to generate the AST with the CSharpProjectManager class.
"Parse a Project"
pm:= CSharpProjectManager new.
pm parseCSharpProject: 'pathTo/HelloWorld'.Save the parsed project with its AST into a ston file and load it whenever you want.
"Save"
pm saveParsingTo: '/home/naparicio/Pharo/files/analysis.ston'.
"Load"
pm loadParsing: '/home/naparicio/Pharo/files/analysis.ston'.To detect code smells in your project you need to add detectors to the project manager. Each detector role is to find an specific code smell in the project he is added to. To detect a code smell you need to instanciate the code smell detector and then add it to the project manager.
"Create detector of Too Many Methods in a class code smell"
detector := CSDetectorTooManyMethods new.
"Specify if you want, how many methods in a class is too many for the detector to catch"
detector length: 15.
"Add detector"
pm addDetector: detector.You now have a Project Manager with one code smell detector. To analyze and detect the code smell in your project simply call this:
pm detectCodeSmells.This will give you a text report of what code smells the detector/s found in your project.
To start the server run:
|csaAPI|
csaAPI := CSharpAnalysisAPI new.
csaAPI startServer.