Giter Club home page Giter Club logo

sonar-delphi's People

Contributors

bellingard avatar darianmiller avatar ehartmann avatar fabriciocolombo avatar godin avatar juris-greitans avatar przemyslawkociolek avatar qgppl avatar teloah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sonar-delphi's Issues

Metric 'class_complexity' should not be computed by a Sensor

Using SonarQube server 6.2 and SonarQube Scanner 2.8

ERROR: Error during SonarQube Scanner execution
java.lang.UnsupportedOperationException: Metric 'class_complexity' should not be computed by a Sensor
at org.sonar.scanner.sensor.DefaultSensorStorage.saveMeasure(DefaultSensorStorage.java:240)
at org.sonar.scanner.index.DefaultIndex.addMeasure(DefaultIndex.java:231)
at org.sonar.scanner.deprecated.DeprecatedSensorContext.saveMeasure(DeprecatedSensorContext.java:131)
at org.sonar.scanner.deprecated.DeprecatedSensorContext.saveMeasure(DeprecatedSensorContext.java:150)
at org.sonar.plugins.delphi.metrics.ComplexityMetrics.save(ComplexityMetrics.java:213)
at org.sonar.plugins.delphi.DelphiSensor.processMetric(DelphiSensor.java:151)
at org.sonar.plugins.delphi.DelphiSensor.processFiles(DelphiSensor.java:130)
at org.sonar.plugins.delphi.DelphiSensor.analyse(DelphiSensor.java:111)
at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:57)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:49)
at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:78)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:182)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:247)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:242)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:232)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:47)
at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:86)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:115)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:116)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:233)
at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:110)
at org.sonarsource.scanner.cli.Main.execute(Main.java:74)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)

Grammar bug fixes

This issue it's just to keep track of grammar changes.

[6a1bddf] Improve detection of Custom Attributes, Generic Types and Anonymous methods.
[b702c9f] Detect complex array declaration.
[cb8ae84] Detect label usage.
[8c9fbbd] Recognize strict and out keywords as identifiers.
[ce9fdcc] Usage of qualified class as ancestor class.
[6714753] Recognize export keyword as identifier
[567fe76] Support for Code Paged AnsiStrings.
[7ad9289] Accept visibility for record helpers and keyword implements as identifier.

Sonar 5.2 Compatibility: Rule Finder does not fetching rule parameter correctly

Sonar-runner is throwing the following exception:
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
at org.sonar.runner.api.Runner.execute(Runner.java:100)
at org.sonar.runner.Main.executeTask(Main.java:70)
at org.sonar.runner.Main.execute(Main.java:59)
at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.lang.NullPointerException
at org.sonar.plugins.delphi.metrics.ComplexityMetrics.(ComplexityMetrics.java:141)
at org.sonar.plugins.delphi.DelphiSensor.analyse(DelphiSensor.java:111)
at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58)
at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50)
at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:98)
at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:100)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:85)
at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:258)
at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:253)
at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:243)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:100)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:85)
at org.sonar.batch.bootstrap.GlobalContainer.executeAnalysis(GlobalContainer.java:153)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:110)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:76)
at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)

Debugging the error I find out that the rule finder is fetching empty params
sonar-remote-debugger.

Nested functions break unused arguments rule

UnusedArgumentsRule cannot find used parameters if there is a nested function or procedure.

unit NestedParams;

interface

procedure TestNestedParams(const aValue : string);

implementation

procedure TestNestedParams(const aValue : string);
// "Unused argument: 'avalue' at TestNestedParams" gets added here
var
  lData : string;

  function Update(const aParam : string) : string;
  begin
    Result := aParam + ' dummy';
  end;

begin
  lData := Update(aValue);
end;

end.

NullPointerException excluding all delphi files

I was having NullPointerException analyzing delphi files so I decided to exclude all delphi folders from the plugin configuration page. The error is still ocurring and the amount of files to parse found is the same as previous runs of sonar-runner. I've deleted ".sonar" folder from the workspace and ran it again without success.

The end of the log follows:

12:03:10.393 INFO - Sensor DelphiSensor
12:03:10.403 INFO - No include directories found in project configuration.
12:03:11.057 INFO - Excluded: G:\TeamCity\buildAgent\work\10d8c6b1945a900a\Common
12:03:11.058 INFO - Excluded: G:\TeamCity\buildAgent\work\10d8c6b1945a900a\TCH
12:03:11.058 INFO - Excluded: G:\TeamCity\buildAgent\work\10d8c6b1945a900a\OrtBo
12:03:11.059 INFO - Excluded: G:\TeamCity\buildAgent\work\10d8c6b1945a900a\Obsolete
12:03:11.059 INFO - Excluded: G:\TeamCity\buildAgent\work\10d8c6b1945a900a\build
12:03:11.060 INFO - Excluded: G:\TeamCity\buildAgent\work\10d8c6b1945a900a\Design
12:03:11.060 INFO - Excluded: G:\TeamCity\buildAgent\work\10d8c6b1945a900a\ImportFiles
12:03:11.061 INFO - Excluded: G:\TeamCity\buildAgent\work\10d8c6b1945a900a\NANT
12:03:11.062 INFO - Parsing project Default Project
12:03:11.077 INFO - Files to parse: 959
12:03:11.089 INFO - 0% done...
12:03:11.098 INFO - 10% done...
12:03:11.102 INFO - 20% done...
12:03:11.105 INFO - 30% done...
12:03:11.107 INFO - 40% done...
12:03:11.110 INFO - 50% done...
12:03:11.112 INFO - 60% done...
12:03:11.119 INFO - 70% done...
12:03:11.125 INFO - 80% done...
12:03:11.143 INFO - 90% done...
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 5:38.917s
Final Memory: 6M/117M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
at org.sonar.runner.api.Runner.execute(Runner.java:100)
at org.sonar.runner.Main.executeTask(Main.java:70)
at org.sonar.runner.Main.execute(Main.java:59)
at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.lang.NullPointerException
at org.sonar.plugins.delphi.DelphiSensor.parseFiles(DelphiSensor.java:200)
at org.sonar.plugins.delphi.DelphiSensor.analyse(DelphiSensor.java:107)
at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:57)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:49)
at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:78)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:184)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:241)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:236)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:226)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:47)
at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:86)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:115)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:118)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:78)
at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
... 9 more

Add new rule: Classes should not be too complex

Even when the Cyclomatic Complexity of a class is very high, this complexity might be well distributed among all methods. Nevertheless, most of the time, a very complex class is a class which breaks the Single Responsibility Principle and which should be re-factored to be split in several classes.

Maximum complexity allowed: 200

"Empty begin statement" issue is not generated properly for several empty procedures in a row

"Empty begin statement" issue will be generated only for procedures One, Three and Five.

unit EmptyProcs;

interface

type
  TEmptyProcs = class
  public
    procedure One;
    procedure Two;
    procedure Three;
    procedure Four;
    procedure Five;
  end;

implementation

procedure TEmptyProcs.One;
begin

end;

procedure TEmptyProcs.Two;
begin

end;

procedure TEmptyProcs.Three;
begin

end;

procedure TEmptyProcs.Four;
begin

end;

procedure TEmptyProcs.Five;
begin

end;

end.

NullPointerException when I use a Quality profile without "Unused function/procedure."

If I perform a Sonar Analysis with a Quality profile that does not contain Unused function/procedure., it throws NullPointerException.

ERROR: Error during SonarQube Scanner execution
java.lang.NullPointerException
at org.sonar.plugins.delphi.metrics.DeadCodeMetrics.save(DeadCodeMetrics.java:167)
at org.sonar.plugins.delphi.DelphiSensor.processFiles(DelphiSensor.java:134)
at org.sonar.plugins.delphi.DelphiSensor.analyse(DelphiSensor.java:112)
at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58)
at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50)
at org.sonar.batch.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:83)
at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:189)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:265)
at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:260)
at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:250)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
at org.sonar.batch.scan.ProjectScanContainer.startComponents(ProjectScanContainer.java:128)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
at org.sonar.batch.task.ScanTask.execute(ScanTask.java:55)
at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:124)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:240)
at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:110)
at org.sonarsource.scanner.cli.Main.execute(Main.java:72)
at org.sonarsource.scanner.cli.Main.main(Main.java:60)

Sets are reported as type aliases

This code generates "Do not use type aliases" issue for TSuits:

unit SetTest;

interface

type
  TSuit = (stHearts, stSpades, stDiamonds, stClubs);
  TSuits = set of TSuit;

implementation

end.

Grammar: expression with nested generics is not parsed

Hi,

The grammar does not understand expressions where two generics are nested. For example, consider following code:

aObj := TList<TList<Integer>>.Create;

A pull request with my version of the fix will follow shortly :-)

NullPointerException

2016-04-11T10:02:50.7167593Z ##[error]Caused by: java.lang.NullPointerException
2016-04-11T10:02:50.7167593Z ##[error]at org.sonar.plugins.delphi.DelphiSensor.parseFiles(DelphiSensor.java:200)
2016-04-11T10:02:50.7167593Z ##[error]at org.sonar.plugins.delphi.DelphiSensor.analyse(DelphiSensor.java:107)
2016-04-11T10:02:50.7167593Z ##[error]at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58)
2016-04-11T10:02:50.7167593Z ##[error]at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50)
2016-04-11T10:02:50.7167593Z ##[error]at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:98)

This is an excerpt of the log of the sonar-runner execution, for a project which doesn't include any Delphi sources. The sonar-runner is being invoked through the TFS vso-agent-task SonarQube Post Test

2016-04-11T10:00:35.8735554Z SonarQube Runner 2.4
2016-04-11T10:00:35.8735554Z Java 1.8.0_45 Oracle Corporation (64-bit)
2016-04-11T10:00:35.8735554Z Windows Server 2012 R2 6.3 amd64
2016-04-11T10:00:35.8735554Z SONAR_RUNNER_OPTS=-Xmx1024m
2016-04-11T10:00:35.8735554Z INFO: Error stacktraces are turned on.
2016-04-11T10:00:35.8735554Z INFO: Runner configuration file: d:\TfsData\_work\6\.sonarqube\bin\sonar-runner\bin\..\conf\sonar-runner.properties
2016-04-11T10:00:35.8735554Z INFO: Project configuration file: d:\TfsData\_work\6\.sonarqube\out\sonar-project.properties
2016-04-11T10:00:35.9828704Z INFO: Default locale: "fr_FR", source code encoding: "UTF-8"
2016-04-11T10:00:35.9828704Z INFO: Work directory: d:\TfsData\_work\6\.sonarqube\out\.sonar
2016-04-11T10:00:36.2040890Z INFO: SonarQube Server 5.3

FunctionParametersAnalyzer crash with NullPointerException

FunctionParametersAnalyzer crash with NullPointerException because results.getActiveFunction() returns null.

[ERROR] [12:50:31.145] Error analyzing file: null 
java.lang.NullPointerException: null
        at org.sonar.plugins.delphi.antlr.analyzer.impl.FunctionParametersAnalyzer.doAnalyze(FunctionParametersAnalyzer.java:50) ~[sonar-delphi-plugin-0.3.3-SNAPSHOT.jar:na]
        at org.sonar.plugins.delphi.antlr.analyzer.CodeAnalyzer.analyze(CodeAnalyzer.java:51) ~[sonar-delphi-plugin-0.3.3-SNAPSHOT.jar:na]
        at org.sonar.plugins.delphi.antlr.analyzer.CodeAnalyzer.analyze(CodeAnalyzer.java:54) ~[sonar-delphi-plugin-0.3.3-SNAPSHOT.jar:na]
        at org.sonar.plugins.delphi.antlr.analyzer.CodeAnalyzer.analyze(CodeAnalyzer.java:54) ~[sonar-delphi-plugin-0.3.3-SNAPSHOT.jar:na]
        at org.sonar.plugins.delphi.antlr.analyzer.CodeAnalyzer.analyze(CodeAnalyzer.java:54) ~[sonar-delphi-plugin-0.3.3-SNAPSHOT.jar:na]
        at org.sonar.plugins.delphi.antlr.analyzer.CodeAnalyzer.analyze(CodeAnalyzer.java:54) ~[sonar-delphi-plugin-0.3.3-SNAPSHOT.jar:na]
        at org.sonar.plugins.delphi.antlr.analyzer.CodeAnalyzer.analyze(CodeAnalyzer.java:54) ~[sonar-delphi-plugin-0.3.3-SNAPSHOT.jar:na]
        at org.sonar.plugins.delphi.antlr.analyzer.CodeAnalyzer.analyze(CodeAnalyzer.java:54) ~[sonar-delphi-plugin-0.3.3-SNAPSHOT.jar:na]
        at org.sonar.plugins.delphi.antlr.analyzer.CodeAnalyzer.analyze(CodeAnalyzer.java:54) ~[sonar-delphi-plugin-0.3.3-SNAPSHOT.jar:na]
        at org.sonar.plugins.delphi.antlr.analyzer.CodeAnalyzer.analyze(CodeAnalyzer.java:54) ~[sonar-delphi-plugin-0.3.3-SNAPSHOT.jar:na]
        at org.sonar.plugins.delphi.antlr.analyzer.CodeAnalyzer.analyze(CodeAnalyzer.java:54) ~[sonar-delphi-plugin-0.3.3-SNAPSHOT.jar:na]
        at org.sonar.plugins.delphi.antlr.analyzer.CodeAnalyzer.analyze(CodeAnalyzer.java:54) ~[sonar-delphi-plugin-0.3.3-SNAPSHOT.jar:na]
        at org.sonar.plugins.delphi.antlr.analyzer.DelphiASTAnalyzer.analyze(DelphiASTAnalyzer.java:69) ~[sonar-delphi-plugin-0.3.3-SNAPSHOT.jar:na]
        at org.sonar.plugins.delphi.DelphiSensor.analyseSourceFile(DelphiSensor.java:266) [sonar-delphi-plugin-0.3.3-SNAPSHOT.jar:na]
        at org.sonar.plugins.delphi.DelphiSensor.parseSourceFile(DelphiSensor.java:238) [sonar-delphi-plugin-0.3.3-SNAPSHOT.jar:na]
        at org.sonar.plugins.delphi.DelphiSensor.parseFiles(DelphiSensor.java:197) [sonar-delphi-plugin-0.3.3-SNAPSHOT.jar:na]
        at org.sonar.plugins.delphi.DelphiSensor.analyse(DelphiSensor.java:108) [sonar-delphi-plugin-0.3.3-SNAPSHOT.jar:na]
        at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:79) [sonar-batch-maven-compat-4.5.6.jar:na]
        at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:70) [sonar-batch-maven-compat-4.5.6.jar:na]
        at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:119) [sonar-batch-maven-compat-4.5.6.jar:na]
        at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:194) [sonar-batch-maven-compat-4.5.6.jar:na]
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93) [sonar-batch-maven-compat-4.5.6.jar:na]
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78) [sonar-batch-maven-compat-4.5.6.jar:na]
        at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:233) [sonar-batch-maven-compat-4.5.6.jar:na]
        at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:228) [sonar-batch-maven-compat-4.5.6.jar:na]
        at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:221) [sonar-batch-maven-compat-4.5.6.jar:na]
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93) [sonar-batch-maven-compat-4.5.6.jar:na]
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78) [sonar-batch-maven-compat-4.5.6.jar:na]
        at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:64) [sonar-batch-maven-compat-4.5.6.jar:na]
        at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:51) [sonar-batch-maven-compat-4.5.6.jar:na]
        at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:125) [sonar-batch-maven-compat-4.5.6.jar:na]
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93) [sonar-batch-maven-compat-4.5.6.jar:na]
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78) [sonar-batch-maven-compat-4.5.6.jar:na]
        at org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapContainer.java:173) [sonar-batch-maven-compat-4.5.6.jar:na]
        at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95) [sonar-batch-maven-compat-4.5.6.jar:na]
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67) [sonar-batch-maven-compat-4.5.6.jar:na]
        at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48) [sonar-runner-batch2874009670404545447.jar:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_31]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_31]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_31]
        at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_31]
        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87) [sonar-runner-api-2.4.jar:na]
        at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75) [sonar-runner-api-2.4.jar:na]
        at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_31]
        at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69) [sonar-runner-api-2.4.jar:na]
        at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50) [sonar-runner-api-2.4.jar:na]
        at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102) [sonar-runner-api-2.4.jar:na]
        at org.sonar.runner.api.Runner.execute(Runner.java:100) [sonar-runner-api-2.4.jar:na]
        at org.codehaus.mojo.sonar.bootstrap.RunnerBootstraper.execute(RunnerBootstraper.java:135) [sonar-maven-plugin-2.6.jar:na]
        at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:132) [sonar-maven-plugin-2.6.jar:na]
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) [maven-core-3.0.5.jar:3.0.5]
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) [maven-core-3.0.5.jar:3.0.5]
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) [maven-core-3.0.5.jar:3.0.5]
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) [maven-core-3.0.5.jar:3.0.5]
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) [maven-core-3.0.5.jar:3.0.5]
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) [maven-core-3.0.5.jar:3.0.5]
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) [maven-core-3.0.5.jar:3.0.5]
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) [maven-core-3.0.5.jar:3.0.5]
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) [maven-core-3.0.5.jar:3.0.5]
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) [maven-core-3.0.5.jar:3.0.5]
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) [maven-embedder-3.0.5.jar:3.0.5]
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) [maven-embedder-3.0.5.jar:3.0.5]
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) [maven-embedder-3.0.5.jar:3.0.5]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_31]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_31]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_31]
        at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_31]
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) [plexus-classworlds-2.4.jar:na]
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) [plexus-classworlds-2.4.jar:na]
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) [plexus-classworlds-2.4.jar:na]
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) [plexus-classworlds-2.4.jar:na]
line 1:12 mismatched character '.' expecting set null

XX is not a valid line for pointer

There is a problem with nested functions.

Scenario

  • two nested functions with the same name in different units.
  • one of this function is located further than end of file with second function
  • functions has problem with Complexity
    Results:
    XX is not a valid line for pointer

Example in attached file.

I added this code

if ((activeFunction != null) && (activeFunction.getUnit() != results.getActiveUnit()))
        activeFunction = null;

in method FunctionInterface createFunction(CodeAnalysisResults results, ClassInterface currentClass)

It solved this problem but it is not a good solution :(

.
Desktop.zip

Crash after the analyse

When my project source directory contents *.pas files, after analyse of my delphi code, sonar crash with an null pointer exception. I use Sonar 5.2 (latest) and the sonar-delphi-plugin 0.3.2.

I launch the sonar-runner from the directory with the following sonar-project.properties file :

sonar.projectKey=GRANT
sonar.projectName=Grant
sonar.projectVersion=1.0
sonar.sources=./workspace
sonar.language=delph

The error stack :

15:49:17.476 INFO - 100% done...
15:49:17.476 INFO - Done
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 14.469s
Final Memory: 44M/728M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
at org.sonar.runner.api.Runner.execute(Runner.java:100)
at org.sonar.runner.Main.executeTask(Main.java:70)
at org.sonar.runner.Main.execute(Main.java:59)
at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.lang.NullPointerException
at org.sonar.plugins.delphi.metrics.ComplexityMetrics.(ComplexityMetrics.java:141)
at org.sonar.plugins.delphi.DelphiSensor.analyse(DelphiSensor.java:111)
at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58)
at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50)
at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:98)
at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:100)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:85)
at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:258)
at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:253)
at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:243)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:100)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:85)
at org.sonar.batch.bootstrap.GlobalContainer.executeAnalysis(GlobalContainer.java:153)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:110)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:76)
at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
... 9 more

Grammar don't parse Interface Implementation using Method Resolution Clause

unit InterfaceMethodResolutionClause;

interface

type
  IInterfaceA = interface
    ['{D9434374-0D61-44A6-A84B-06F574F140BE}']
    procedure DoSomething;
  end;

  IInterfaceB = interface
    ['{D9434374-0D61-44A6-A84B-06F574F140BE}']
    procedure DoSomethingToo;
  end;

  TMyClass = class(TInterfacedObject, IInterfaceA, IInterfaceB)
  public
    procedure DoSomething;
    procedure IInterfaceB.DoSomethingToo = DoSomething;
  end;

implementation

{ TMyClass }

procedure TMyClass.DoSomething;
begin
  Writeln('Do Something');
end;

end.

Accept PACKAGE keyword as identifier

The following code causes a parser error because PACKAGE is treated as a keyword.

unit PackageAsIdentifier;

interface

implementation

var
  Package: Boolean;

end.

Crash with pointer on a not valid line

Sonar crash during analyse (file with the problem : EPSSCallBackController.zip) :

INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 23.984s
Final Memory: 51M/823M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
at org.sonar.runner.api.Runner.execute(Runner.java:100)
at org.sonar.runner.Main.executeTask(Main.java:70)
at org.sonar.runner.Main.execute(Main.java:59)
at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.lang.IllegalArgumentException: 711 is not a valid line for pointer. File [moduleKey=GRANT, relative=work
space/EPERMIT.XE8/EPERMITSS00/EPSSCallBackController.pas, basedir=E:\jenkins\jobs\Grant] has 147 line(s)
at org.sonar.api.internal.google.common.base.Preconditions.checkArgument(Preconditions.java:148)
at org.sonar.api.batch.fs.internal.DefaultInputFile.checkValid(DefaultInputFile.java:214)
at org.sonar.api.batch.fs.internal.DefaultInputFile.newPointer(DefaultInputFile.java:208)
at org.sonar.api.batch.fs.internal.DefaultInputFile.selectLine(DefaultInputFile.java:243)
at org.sonar.batch.issue.DeprecatedIssueBuilderWrapper.line(DeprecatedIssueBuilderWrapper.java:59)
at org.sonar.plugins.delphi.metrics.ComplexityMetrics.addIssue(ComplexityMetrics.java:281)
at org.sonar.plugins.delphi.metrics.ComplexityMetrics.processFunction(ComplexityMetrics.java:191)
at org.sonar.plugins.delphi.metrics.ComplexityMetrics.analyse(ComplexityMetrics.java:144)
at org.sonar.plugins.delphi.DelphiSensor.processFiles(DelphiSensor.java:131)
at org.sonar.plugins.delphi.DelphiSensor.analyse(DelphiSensor.java:112)
at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58)
at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50)
at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:98)
at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:100)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:85)
at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:258)
at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:253)
at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:243)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:100)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:85)
at org.sonar.batch.bootstrap.GlobalContainer.executeAnalysis(GlobalContainer.java:153)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:110)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:76)
at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
... 9 more

NullPointerException on connecting to mssql database

Hi,

I'm attempting to read code-coverage results from AQTime that have been exported to an MSSQL database and I keep running into a NullPointerException.

INFO: Sensor Delphi Code Coverage Sensor DEBUG: Code Coverage starting... ERROR: com.microsoft.sqlserver.jdbc.SQLServerDriver INFO: ------------------------------------------------------------------------ INFO: EXECUTION FAILURE INFO: ------------------------------------------------------------------------ INFO: Total time: 39.743s INFO: Final Memory: 133M/1437M INFO: ------------------------------------------------------------------------ ERROR: Error during SonarQube Scanner execution java.lang.NullPointerException at org.sonar.plugins.delphi.codecoverage.aqtime.JdbcTemplate.query(JdbcTemplate.java:62) at org.sonar.plugins.delphi.codecoverage.aqtime.AQTimeCoverageDao.readAQTimeCodeCoverage(AQTimeCoverageDao.java:56) at org.sonar.plugins.delphi.codecoverage.aqtime.AQTimeCoverageParser.parse(AQTimeCoverageParser.java:60) at org.sonar.plugins.delphi.codecoverage.CodeCoverageSensor.analyse(CodeCoverageSensor.java:92) at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58) at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50) at org.sonar.batch.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:83) at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:241) at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:236) at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:226) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) at org.sonar.batch.task.ScanTask.execute(ScanTask.java:47) at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:106) at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119) at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:62) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60) at com.sun.proxy.$Proxy0.execute(Unknown Source) at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:244) at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:154) at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:110) at org.sonarsource.scanner.cli.Main.execute(Main.java:72) at org.sonarsource.scanner.cli.Main.main(Main.java:60)

I've been trying for hours using different connection settings and nothing makes a difference.
The settings I'm using are these: https://i.gyazo.com/18e4776769db5354f59f89796d1b0df1.png

I think this is a bug. I hope this could be fixed because my employer would very much like to use this feature.

ANTLR "constExpression" parser exception

I've found a bug in parser of many classes of my app.
It's impossible to continue the analysis with those errors...
I've attached the source file and exception stack trace.

Source File:
EDevice.pas.zip

Exception:
Caused by: org.antlr.runtime.tree.RewriteEmptyStreamException: rule constExpression at org.antlr.runtime.tree.RewriteRuleElementStream._next(RewriteRuleElementStream.java:157) at org.antlr.runtime.tree.RewriteRuleElementStream.nextTree(RewriteRuleElementStream.java:144) at org.sonar.plugins.delphi.antlr.DelphiParser.constDeclaration(DelphiParser.java:3935) at org.sonar.plugins.delphi.antlr.DelphiParser.constSection(DelphiParser.java:3596) at org.sonar.plugins.delphi.antlr.DelphiParser.interfaceDecl(DelphiParser.java:3328) at org.sonar.plugins.delphi.antlr.DelphiParser.unitInterface(DelphiParser.java:1466) at org.sonar.plugins.delphi.antlr.DelphiParser.unit(DelphiParser.java:1222) at org.sonar.plugins.delphi.antlr.DelphiParser.file(DelphiParser.java:411) at org.sonar.plugins.delphi.antlr.ast.DelphiAST.<init>(DelphiAST.java:84) at org.sonar.plugins.delphi.DelphiSensor.analyseSourceFile(DelphiSensor.java:258) at org.sonar.plugins.delphi.DelphiSensor.parseSourceFile(DelphiSensor.java:235) at org.sonar.plugins.delphi.DelphiSensor.parseFiles(DelphiSensor.java:200) at org.sonar.plugins.delphi.DelphiSensor.analyse(DelphiSensor.java:108) at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58) at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50) at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:98) at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:185) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:132) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:117) at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:243) at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:238) at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:236) at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:228) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:132) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:117) at org.sonar.batch.task.ScanTask.execute(ScanTask.java:55) at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:132) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:117) at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:122) at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119) at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:79) at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)

One Class per File Rule should ignore inner Types

The source code bellow generates an issue because inner types are counted.

unit InnerClass;

interface

type
  TOuterClass = class
  strict private
    type
      TInnerClass1 = class
      end;
      TInnerClass2 = class
      end;
  end;

implementation

end.

Accept STORED keyword as identifier

The following code causes a parser error because STORED was treated as a keyword.

unit KeyWordsAsIdentifier;

interface

implementation

var
  Stored: Boolean;

end.

No metric (PUBLIC_API) for org.sonar.plugins.delphi.metrics.ComplexityMetrics

Greetings,
I have problem running Delphi project analysis. Every time after parsing I am getting error:
No metric (PUBLIC_API) for org.sonar.plugins.delphi.metrics.ComplexityMetrics@46f3a146

To be honest I am not sure what metric in Sonar is, and where to start debugging. the articles covering metrics in Sonar Docs are unavailable :/

Parsing an anonymous function generates "mismatched input" error

Analyzing a unit with an anonymous function generates the following error:

19:31:09.270 INFO  - Parsing project Default Project
19:31:09.271 INFO  - Files to parse: 1
C:\Develop\tmp_work\sonar-test\src\AnonymousFuncTest.pas line 20:26 mismatched input '(' expecting END
19:31:09.640 INFO  - 0% done...
19:31:09.641 INFO  - 10% done...
unit AnonymousFuncTest;

interface

type
  TStringPredicate = reference to function(const aValue : string) : Boolean;

function StringMatches(const aValue : string; aPredicate : TStringPredicate) : Boolean;
function IsStringEmpty(const aValue : string) : Boolean;

implementation

function StringMatches(const aValue : string; aPredicate : TStringPredicate) : Boolean;
begin
  Result := aPredicate(aValue);
end;

function IsStringEmpty(const aValue : string) : Boolean;
begin
  Result := StringMatches(aValue,
    function(const aValue : string) : Boolean
    begin
      Result := aValue = '';
    end);
end;

end.

Fail to decorate

Sorry, after come back to Sonar 5.1.2, I have another crash during analysing :

16:31:01.862 INFO - Execute decorators...
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 32.625s
Final Memory: 33M/1071M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
at org.sonar.runner.api.Runner.execute(Runner.java:100)
at org.sonar.runner.Main.executeTask(Main.java:70)
at org.sonar.runner.Main.execute(Main.java:59)
at org.sonar.runner.Main.main(Main.java:53)
Caused by: org.sonar.api.utils.SonarException: Fail to decorate 'org.sonar.api.resources.File@50fd1535[key=workspace/EPE
RMIT.XE8/EPERMITCP00Tiles/sources/EPFMAIN00.pas,path=workspace/EPERMIT.XE8/EPERMITCP00Tiles/sources/EPFMAIN00.pas,filena
me=EPFMAIN00.pas,language=Delphi]'
at org.sonar.batch.phases.DecoratorsExecutor.executeDecorator(DecoratorsExecutor.java:104)
at org.sonar.batch.phases.DecoratorsExecutor.decorateResource(DecoratorsExecutor.java:87)
at org.sonar.batch.phases.DecoratorsExecutor.decorateResource(DecoratorsExecutor.java:79)
at org.sonar.batch.phases.DecoratorsExecutor.decorateResource(DecoratorsExecutor.java:79)
at org.sonar.batch.phases.DecoratorsExecutor.execute(DecoratorsExecutor.java:71)
at org.sonar.batch.phases.DatabaseModePhaseExecutor.execute(DatabaseModePhaseExecutor.java:127)
at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:264)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:235)
at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:230)
at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:220)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:57)
at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:45)
at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:135)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:158)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
... 9 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1173
at org.sonar.batch.issue.tracking.FileHashes.getHash(FileHashes.java:89)
at org.sonar.batch.issue.tracking.IssueTracking.setChecksumOnNewIssues(IssueTracking.java:66)
at org.sonar.batch.issue.tracking.IssueTracking.track(IssueTracking.java:51)
at org.sonar.batch.issue.tracking.IssueTrackingDecorator.doDecorate(IssueTrackingDecorator.java:139)
at org.sonar.batch.issue.tracking.IssueTrackingDecorator.decorate(IssueTrackingDecorator.java:113)
at org.sonar.batch.phases.DecoratorsExecutor.executeDecorator(DecoratorsExecutor.java:96)
... 36 more

Record constructor in an implementation section causes "NoSemicolonRule" to fail

Declaring a record with a constructor in an implementation section causes NoSemicolonRule to fail with java.lang.ClassCastException error in the line where it adds a violation.

unit RecordConstructor;

interface

implementation

type
  TDummyRec = record
    FData : Integer;
    constructor Create(aData : Integer);
  end;

constructor TDummyRec.Create(aData : Integer);
begin
  inherited;
  FData := aData;
end;

end.

Full stack trace:

ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
        at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
        at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
        at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
        at org.sonar.runner.api.Runner.execute(Runner.java:100)
        at org.sonar.runner.Main.executeTask(Main.java:70)
        at org.sonar.runner.Main.execute(Main.java:59)
        at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.lang.ClassCastException: org.antlr.runtime.tree.CommonTree cannot be cast to org.sonar.plugins.delphi.antlr.ast.DelphiPMDNode
        at org.sonar.plugins.delphi.pmd.rules.NoSemicolonRule.visit(NoSemicolonRule.java:57)
        at org.sonar.plugins.delphi.pmd.rules.DelphiRule.visitAll(DelphiRule.java:86)
        at net.sourceforge.pmd.AbstractJavaRule.apply(AbstractJavaRule.java:87)
        at net.sourceforge.pmd.RuleSet.apply(RuleSet.java:179)
        at org.sonar.plugins.delphi.pmd.profile.DelphiRuleSets.apply(DelphiRuleSets.java:48)
        at org.sonar.plugins.delphi.pmd.DelphiPMD.processFile(DelphiPMD.java:72)
        at org.sonar.plugins.delphi.pmd.DelphiPmdSensor.createPmdReport(DelphiPmdSensor.java:113)
        at org.sonar.plugins.delphi.pmd.DelphiPmdSensor.analyse(DelphiPmdSensor.java:75)
        at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:59)
        at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:51)
        at org.sonar.batch.phases.DatabaseModePhaseExecutor.execute(DatabaseModePhaseExecutor.java:120)
        at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:264)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
        at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:235)
        at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:230)
        at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:220)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
        at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:57)
        at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:45)
        at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:135)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
        at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:158)
        at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
        at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
        ... 9 more

It seems like a grammar error, because record declaration generates a suspicious end in the AST:

(implementation 
 (type 
  (TkNewType 
   (TDummyRec 
    record
    FData 
    (TkVariableType Integer) 
    (constructor 
     (TkFunctionName Create) 
     (TkFunctionArgs 
      (TkVariableIdents aData) 
      (TkVariableType Integer)
     )
    )
    end
   )
  )
 )
)

If the constructor is removed, then this AST is generated and "No semicolon at the end of code block" error is added to FData : Integer; line:

(implementation 
 (type 
  (TkNewType 
   (TDummyRec 
    record
    FData
    (TkVariableType Integer)
    end
   )
  )
 )
)

Add new rule: Methods should not be empty

There are several reasons for a method not to have a method body:

  • It is an unintentional omission, and should be fixed to prevent an unexpected behavior in production.
  • It is not yet, or never will be, supported. In this case an [ENotImplemented|ENotSupportedException] should be raised.
  • The method is an intentionally-blank override. In this case a nested comment should explain the reason for the blank override.

Exception
An abstract class' may have empty methods, in order to provide default implementations for child classes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.