preloz to do hezkeho ceskeho akademickeho textu

Solution Architecture The check has been designed and implemented in Java programming language. It is a project that acts as an extension to the SonarQube, that means it cannot run without being instantiated and executed from SonarQube. That means during the analysis the SonarQube executes its own checks against the code and there is one part of the process when extensions, which were defined to be used on the project, are being executed as well. Hence at that point of analysis our extension gets the time to execute analysis and pass results back to the SonarQube. There is also second time during post analysis is when our extension gets control, therefore we can also make some conclusions on the data we have collected in the first run. 6.1 Implementation of the check As was already slightly described, the tool that we are using enables to add extensions to the checking process in order to enhance analysis about custom information and customize already acquired results. That is the basis for our solution as it is created as a extension to the tool. Furthermore our solution is executed twice, at first during the analysis of a source code and second time for the post analysis of our own results and to send back results of our analysis back to the SonarQube. Analysis with our solution looks like nothing at all and in the interface of the check are shown new information. 6.2 Intermediate data storage Stores scores to every class and respective parts of design patterns are stored in custom object that will be used during the second part of the analysis. This object essentially contains all retrieved classes alongside with the collection of design pattern part attributes and some attributes to ease the work- such as name of the class. This object needed to be created in order to be able to store 74 DesignPatternsJavaSensor DesignPatternsJavaPlugin define(Context) describe(SensorDescriptor) execute(SensorContext) forFileAddIssue(InputFile, RequirementForFile) forFileAddMeasurements(InputFile, PatternPartAttributeInterface) generateMetrics(Iterable<InputFile>) StaticMatrix cuteStaticThing: HashMap f ilesWithContext: HashMap currentRequirementForFile: RequirementForFile allRequirementForFile: HashMap relationStrategies: Map patternVisitorInterfaces: List currentPattern: int currentClassTree: ClassTree pvf: PatternCreationFactory analyzeAllPatternVisitors(Tree) calculateAllMetrics() refreshPatternVisitors() obtainAllPatternPartAttributes() addPatternPartAttributeToList(ClassTree, PatternPartAttributeInterface) startNewRequirementForFile(String) insertContextToNewRequirementForFile(JavaFileScannerContext) insertCurrentJavaCheckToNewRequirementForFile(AstVisitor) insertCurrentClassToNewRequirementForFile() PatternCreationFactory getPatternVisitorz(): List getPatternRelations(): Map getPatternVisitors(): Object[] RequirementForFile addPatternPartAttribute(PatternPartAttributeInterface) PatternVisitorInterface visit() get(): PatternPartAttributeInterface Obrázek 6.1: Static Matrix And Relations AstVisitor RULE_KEY: String context: JavaFileScannerContext scanFile(JavaFileScannerContext) visit() RelationsStrategyInterface calculate(attributes, relatedAttributes, String) forAttribute(): String our data, for otherwise we might have chosen writing all the information to the specific classes in SonarQube’s interface, or storing the data as the file, for example in json format. Next image describes a way how the application behaves during Sensor execution- the main part is that the Sensor is being executed from SonarQube’s context and therefore I have no possibility of passing any data into that class. Hence this is the very reason why does the StaticMatrix class exists, since that one stores data in easy to obtain manner throughout the whole runtime of the application. For otherwise it might be a bit more complicated to pass data between the visitors and Relations used by this sensor. This assumption is based on examination of the SonarQube that there seems to be no straightforward way through which the data might be stored on the server and then obtained back on the client in between the analysis. Hence I used the fact that the analysis runs locally and that the analysis should be done in one go and created this Static Matrix[6.1] that acts as data storage.