You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The entire PLugin follows the GPL: https://github.com/SandroLuck/SonarDelphi/blob/master/src/LUCK_LICENSE.txt
20
-
21
-
Steps to Analyze a Delphi Project
22
-
------------------------------------------------
17
+
## License
23
18
24
-
1. Install SonarQube Server (see [Setup and Upgrade](http://docs.sonarqube.org/display/SONAR/Setup+and+Upgrade) for more details). Check supported versions of the [latest release](https://github.com/fabriciocolombo/sonar-delphi/releases/latest) of the plugin.
25
-
2. Install one of the supported [Runners](#supported-runners) (see below) and be sure you can call it from the directory where you have your source code
26
-
3. Install [Delphi Plugin](https://github.com/mendrix/SonarDelphi/releases) (see [Installing a Plugin](http://docs.sonarqube.org/display/SONAR/Installing+a+Plugin) for more details).
27
-
NOTE: This only applies to SonarQube 7.9(LTS) and heigher. For older versions see [Delphi Plugin](https://github.com/fabriciocolombo/sonar-delphi/releases)
28
-
4. Check the sample project corresponding to your Runner to know which config file you need to create. You can find the samples in [sonar-delphi/samples](https://github.com/fabriciocolombo/sonar-delphi/tree/master/samples).
29
-
5. Run your Analyzer command from the project root dir
30
-
6. Follow the link provided at the end of the analysis to browse your project's quality in SonarQube UI (see: [Browsing SonarQube](http://docs.sonarqube.org/display/SONAR/Browsing+SonarQube))
31
-
32
-
Supported Runners
33
-
----------------------------
34
-
To run an analysis of your Java project, you can use the following Runners:
19
+
The entire PLugin follows the GPL: https://github.com/SandroLuck/SonarDelphi/blob/master/src/LUCK_LICENSE.txt
35
20
36
-
*[SonarQube Scanner](http://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner): recommended for all projects
37
-
* See https://github.com/fabriciocolombo/sonar-delphi for diffrent approacheds which have not been tested yet with 0.3.4
21
+
## Reporting Issues
38
22
39
-
Reporting Issues
40
-
----------------------------
41
23
SonarQube Delphi Plugin uses GitHub's integrated issue tracking system to record bugs and feature
42
24
requests. If you want to raise an issue, please follow the recommendations below:
43
25
@@ -48,8 +30,7 @@ requests. If you want to raise an issue, please follow the recommendations below
48
30
the version of SonarQube Delphi Plugin that you are using, as well as the SonarQube version.
49
31
* If possible try to create a test-case or project that replicates the issue.
50
32
51
-
Implemented Features
52
-
------------------------------------------
33
+
## Implemented Features
53
34
54
35
* Counting lines of code, statements, number of files
55
36
* Counting number of classes, number of packages, methods, accessors
@@ -74,17 +55,33 @@ Implemented Features
74
55
(Optional with DUnit)
75
56
* Test results
76
57
77
-
Code Assumptions
78
-
----------------------------------
58
+
# Steps to Analyze a Delphi Project
59
+
60
+
1. Install SonarQube Server (see [Setup and Upgrade](http://docs.sonarqube.org/display/SONAR/Setup+and+Upgrade) for more details). Check supported versions of the [latest release](https://github.com/fabriciocolombo/sonar-delphi/releases/latest) of the plugin.
61
+
2. Install one of the supported [Runners](#supported-runners) (see below) and be sure you can call it from the directory where you have your source code
62
+
3. Install [Delphi Plugin](https://github.com/mendrix/SonarDelphi/releases) (see [Installing a Plugin](http://docs.sonarqube.org/display/SONAR/Installing+a+Plugin) for more details).
63
+
NOTE: This only applies to SonarQube 7.9(LTS) and heigher. For older versions see [Delphi Plugin](https://github.com/fabriciocolombo/sonar-delphi/releases)
64
+
4. Check the sample project corresponding to your Runner to know which config file you need to create. You can find the samples in [sonar-delphi/samples](https://github.com/fabriciocolombo/sonar-delphi/tree/master/samples).
65
+
5. Run your Analyzer command from the project root dir
66
+
6. Follow the link provided at the end of the analysis to browse your project's quality in SonarQube UI (see: [Browsing SonarQube](http://docs.sonarqube.org/display/SONAR/Browsing+SonarQube))
67
+
68
+
## Supported Runners
69
+
70
+
To run an analysis of your Java project, you can use the following Runners:
71
+
72
+
*[SonarQube Scanner](http://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner): recommended for all projects
73
+
* See https://github.com/fabriciocolombo/sonar-delphi for diffrent approacheds which have not been tested yet with 0.3.4
74
+
75
+
## Code Assumptions
79
76
80
77
* Grammar is NOT case insensitive, but Delphi code is. Plugin deals with it by DelphiSourceSanitizer class, which feeds ANTLR parser lowercase characters (the "LA" method)
81
78
* Number of classes includes: classes, records
82
79
* Directory is count as a package. Number of packages equals number of directories.
83
80
* Preprocessor definitions between {$if xxx} and {$ifend} are removed (DefineResolver class).
84
81
* Sources imported to SonarQube are parsed through IncludeResolver class. It means, that the source will be lowercased and unknown preprocessor definitions will be cut out.
85
82
86
-
CodeCoverage
87
-
-------------------------------
83
+
## CodeCoverage and unit testing
84
+
88
85
CodeCoverage can be done through the [DelphiCodeCoverage tool](https://sourceforge.net/p/delphicodecoverage/git/ci/master/tree/). Use
89
86
90
87
CodeCoverage.exe -xml -xmllines
@@ -94,8 +91,8 @@ to create a XML output that can be importeded through this plugin. Therefore you
To import the testresults from DUnit, you have to use the [DUnit extension] (https://github.com/mendrix/dunit-extension) and use the supplied runner (it is not necessary to change your test classes to TTestCaseExtension).
100
97
101
98
ExitCode := TTestRunnerUtils.RunRegisteredTests;
@@ -113,8 +110,8 @@ You also have to specify where the plugin can find your testfiles. It is importa
113
110
sonar.exclusions=MyTestFiles/*
114
111
sonar.tests=MyTestFiles
115
112
116
-
Unittests with DUnitX
117
-
-------------------------------
113
+
### Unittests with DUnitX
114
+
118
115
It is also possible to import results from [DUnitX](http://docwiki.embarcadero.com/RADStudio/Rio/en/DUnitX_Overview). Therefore you have to add the file
119
116
120
117
DUnitX.Loggers.XML.SonarQube.pas
@@ -131,20 +128,55 @@ To import the resulting XML file, add the following line to your sonar project p
To build a plugin, you need Java 8 and Maven 3.1 (or greater).
142
+
-[JDK](https://jdk.java.net/)
143
+
-[Maven](https://maven.apache.org/)
144
+
145
+
## Compile and test
146
+
147
+
mvn compile
148
+
mvn test
149
+
150
+
### Package as plugin
151
+
152
+
mvn package
153
+
154
+
Now you can copy the plugin from the ```/target/``` directory to the SonarQube plugin directory.
155
+
156
+
### Importing into Eclipse
157
+
142
158
First run the eclipse maven goal:
143
159
144
160
mvn eclipse:eclipse
145
161
146
162
The project can then be imported into Eclipse using File -> Import and then selecting General -> Existing Projects into Workspace.
147
163
148
-
Importing into Intellij
149
-
-------------------------------
164
+
### Importing into Intellij
165
+
150
166
Simply open the pom.xml in Intellij should solve most dependecies by itself.
167
+
168
+
# How to develop and debug the plugin
169
+
170
+
SonarQube has great documentation about [developing a plugin](https://docs.sonarqube.org/latest/extend/developing-plugin/). To debug this plugin with the SonarQube scanner you to just set the following environment variable (on Windows):
171
+
172
+
SET SONAR_SCANNER_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000"
173
+
174
+
Now you attach your Eclipse (or other) debugger to port 8000 to start debugging.
175
+
176
+
## Changing the grammar with ANLTRWorks
177
+
178
+
The plugin uses an ANTLR3 grammar to parse the Delphi language. The grammar definition can be found in **/src/main/antlr3/org/sonar/plugins/delphi/antlr/delphi.g**. An easy way to check and modify this grammar is using [ANTLRWorks](https://www.antlr3.org/works/). Here you can test your grammar on new files and implement new language definitions.
179
+
180
+
After successfully changing and testing the Delphi.g grammar you have to generate the new parser code (menu Generate, option Generate Code). Now copy the files **DelphiLexer.java** and **DelphiParser.java** from **/src/main/antlr3/org/sonar/plugins/delphi/antlr/output/** to **/src/main/java/org/sonar/plugins/delphi/antlr/** and (re)build the plugin.
181
+
182
+
Note: it is important to make sure your new grammar changes are also tested. If you only have to make sure that they can be parsed without errors, you can add your new language features to one of the existing grammar files in **/src/main/java/org/sonar/plugins/delphi/antlr** (the newest is **GrammarTest2020.pas**).
0 commit comments