GithubHelp home page GithubHelp logo

jam-software / sonardelphi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mendrix/sonardelphi

31.0 31.0 12.0 2.37 MB

This repository contains the source code to the Sonar-Delphi plugin. Can be used to analyse Delphi projects with SonarQube.

GAP 5.47% Java 87.34% Pascal 7.13% C++ 0.02% Batchfile 0.04% SourcePawn 0.01%
delphi sonardelphi sonarqube

sonardelphi's People

Contributors

ekot1 avatar joachimmarder avatar laurensvanrun avatar sandroluck avatar x3ntrix 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

sonardelphi's Issues

Warning because ruleset name and description are missing

The plugin is producing two warnings regarding the rule set in the console output, which should be easily fixable.

17:22:37.582 INFO: Done
17:22:37.582 INFO: Sensor Combined LCOV and LOC sensor [delphi] (done) | time=9981ms
17:22:37.582 INFO: Sensor Delphi SurefireSensor [delphi]
17:22:37.582 INFO: Delphi sensor execute...
17:22:37.582 WARN: No Surefire reports directory found! Using default directory: target/surefire-reports
17:22:37.582 WARN: surefire report path not found F:\workspace\SB_trunk\target\surefire-reports
17:22:37.582 INFO: Sensor Delphi SurefireSensor [delphi] (done) | time=0ms
17:22:37.582 INFO: Sensor PMD sensor [delphi]
17:22:37.582 INFO: PMD sensor.execute
17:22:37.736 INFO: PMD configuration: F:\workspace\SB_trunk\.scannerwork\delph.xml
Nov 16, 2021 5:22:37 PM net.sourceforge.pmd.RuleSetFactory parseRuleSetNode
WARNING: RuleSet name is missing. Future versions of PMD will require it.
Nov 16, 2021 5:22:37 PM net.sourceforge.pmd.RuleSetFactory parseRuleSetNode
WARNING: RuleSet description is missing. Future versions of PMD will require it.
17:22:37.796 INFO: No include directories found in project configuration.
17:22:37.797 INFO: PMD Parsing project Default Project
17:22:37.797 INFO: 0% done...
17:22:38.227 INFO: 10% done...

UnusedArgumentsRule should check if method is an implementation of an event

I have a Code Smell "Unused argument: AMyUnusedParam at TFormTest.MyComponentMyEventImplementation" for the example below

procedure TFormTest.MyComponentMyEventImplementation(AMyUnusedParam: TSomeRandomType);
begin
  inherited;
{*
  Some code that doesn't use "AMyUnusedParam"
*}
end;

I think this rule should check if the method is a implementation of an event before mark the params as code smells.
Generally the code in events not necessarly need to use all the parameters as they exists only to comply with the event declaration.

Error: Analyzing class parents for no active class

Sonar 8.2
Scanner 4.2
Plugin 1.0.7

I Catch an error when I parse a unit that has undeclared CustomAttributes on it.
When the declaration and usage are in the same file the error does not occur.
Error details:

07:02:58.203 DEBUG: >> PARSING C:\Fontes\Delphi\SonarQube\DelphiProjectForSonar\CustonAtrib.View.SonarQube.pas
07:02:58.534 DEBUG: Error analyzing file: Analyzing class parents for no active class C:\Fontes\Delphi\SonarQube\DelphiProjectForSonar\CustonAtrib.View.SonarQube.pas
java.lang.IllegalStateException: Analyzing class parents for no active class
        at org.sonar.plugins.delphi.antlr.analyzer.impl.TypeInheritanceAnalyzer.doAnalyze(TypeInheritanceAnalyzer.java:43)
        at org.sonar.plugins.delphi.antlr.analyzer.CodeAnalyzer.analyze(CodeAnalyzer.java:51)
        at org.sonar.plugins.delphi.antlr.analyzer.CodeAnalyzer.analyze(CodeAnalyzer.java:54)
        at org.sonar.plugins.delphi.antlr.analyzer.CodeAnalyzer.analyze(CodeAnalyzer.java:54)
        at org.sonar.plugins.delphi.antlr.analyzer.CodeAnalyzer.analyze(CodeAnalyzer.java:54)
        at org.sonar.plugins.delphi.antlr.analyzer.CodeAnalyzer.analyze(CodeAnalyzer.java:54)
        at org.sonar.plugins.delphi.antlr.analyzer.CodeAnalyzer.analyze(CodeAnalyzer.java:54)
        at org.sonar.plugins.delphi.antlr.analyzer.DelphiASTAnalyzer.analyze(DelphiASTAnalyzer.java:57)
        at org.sonar.plugins.delphi.DelphiSensor.analyseSourceFile(DelphiSensor.java:308)
        at org.sonar.plugins.delphi.DelphiSensor.parseSourceFile(DelphiSensor.java:278)
        at org.sonar.plugins.delphi.DelphiSensor.parseFiles(DelphiSensor.java:257)
        at org.sonar.plugins.delphi.DelphiSensor.execute(DelphiSensor.java:117)
        at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
        at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
        at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:386)
        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:382)
        at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:351)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
        at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
        at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
        at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/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:189)
        at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
        at org.sonarsource.scanner.cli.Main.main(Main.java:61)

Example project:
DelphiProjectForSonar

Downloading the plugin in the .jar file

Can you please upload the plugin in .jar format for download? I need to install it in Sonarqube helm chart which supports plugins in .jar format. Thanks in advance.

Fix illegal reflective access

When running the plugin with Java > 8, it reports this warning:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.thoughtworks.xstream.core.util.Fields (file:/C:/Users/CIUser/.sonar/cache/a4ec2f3af08969606e86a41958fd4a7a/sonar-delphi-plugin.jar_unzip/META-INF/lib/xstream-1.4.11.jar) to field java.util.TreeMap.comparator
WARNING: Please consider reporting this to the maintainers of com.thoughtworks.xstream.core.util.Fields
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

By default, only the first access is printed. Therefore, there could be more problems.
With Java >= 16 the access is denied by default and the code probably fails.

Empty 'begin' statement

When we use compilation directive it is understood that the block is empty.

procedure TFormPrincipal.FormCreate(Sender: TObject);
begin
{$IFDEF ANDROID}
PermissionsService.RequestPermissions([`
JStringToString(TJManifest_permission.JavaClass.READ_EXTERNAL_STORAGE),
JStringToString(TJManifest_permission.JavaClass.WRITE_EXTERNAL_STORAGE)],
nil, nil);
{$ENDIF}

end;

Unit tests are not compatible with 8.0 API

Currently, the plugin builds against the 7.9 API. SonarQube 8.0 removed some deprecated code, which is still used. This causes that the unit tests can no longer be build.

Parsing fails for class variables in record helpers

Scan the following code with SonarDelphi:

unit RecordHelperTest;

interface

type

  // This works
  TSomeClass = class(TObject)
    class var fSomeClassVar: ISomeInterface;
  end;

  // This doesn't
  TSomeRecordHelper = record helper for xzy
    class var fSomeClassVar: ISomeInterface;
  end;

implementation

end.

Units flagged as deprecated do match "UnitNameRule"

Every Unit flagged as deprecated matches the "UnitNameRule"

Sample:
unit My.Test.Unit deprecated 'Should no longer be used!';
...
-> UnitNameRule matches, which is not reasonable in my opinion (False positive)

Improve support for $if statements

Currently all code in an $if statement is being removed. Propsed chnage: Inlcude code in $if but remove code in $else part, that would make code like this work:

const 
  cLength =
{$if CompilerVersion >= 22}
   500;	
{$else}
   250;
{$ifend}

Move this project to a dedicated organization to combine efforts

Hi,

More than a year ago I revitalized the SonarDelphi project that had been inactive for too long and was not compatible anymore with the newest SonarQube. Now I see that you (JAM-Software / @joachimmarder) do a lot of development and that is really great to see!

I would like to invite you to combine efforts and move this project to a dedicated 'Organization' (eg. SonarDelphi) so that we can centralize all effort. What do you think of this idea?

Best regards, Laurens

Receiving plenty of errors while parsing code

I am using SonarQube 9.1 with the latest plugin version 1.0.7

When running the Code Analysis from Azure DevOps, I receive lots of errors on the console (see below).

Is there a way to get around these issues?

Kind regards, Harald

Output (extract):

##[error]$SOME-PATH$\uFunctions.IPC.pas line 47:2 mismatched input 'TIPCAsyncDataServer' expecting IMPLEMENTATION
$SOME-PATH$\uFunctions.IPC.pas line 47:2 mismatched input 'TIPCAsyncDataServer' expecting IMPLEMENTATION
##[error]$SOME-PATH$\uFunctions.IPC.pas line 78:5 mismatched input ';' expecting DOT
$SOME-PATH$\uFunctions.IPC.pas line 78:5 mismatched input ';' expecting DOT
##[error]ERROR: Error while parsing $SOME-PATH$\uFunctions.IPC.pas

INFO: 20% done...
INFO: 30% done...
INFO: 40% done...
##[error]$SOME-PATH$\Web.Win.Sockets.pas line 857:0 no viable alternative at input 'begin'
$SOME-PATH$\Web.Win.Sockets.pas line 857:0 no viable alternative at input 'begin'
##[error]$SOME-PATH$\Web.Win.Sockets.pas line 858:2 no viable alternative at input 'Result'

##[error]ERROR: Error while parsing $SOME-PATH$\Web.Win.Sockets.pas
ERROR: Error while parsing $SOME-PATH$\Web.Win.Sockets.pas
INFO: 50% done...
INFO: 60% done...
##[error]$SOME-PATH$\uConnection.Provider.pas line 196:2 no viable alternative at input 'TConnectionProviderSingleton'
$SOME-PATH$\uConnection.Provider.pas line 196:2 no viable alternative at input 'TConnectionProviderSingleton'
##[error]ERROR: Error while parsing $SOME-PATH$\uConnection.Provider.pas
ERROR: Error while parsing $SOME-PATH$\uConnection.Provider.pas
INFO: 70% done...
INFO: 80% done...
INFO: 90% done...
INFO: Done
INFO: Processing metrics...
INFO: 0% done...
##[error]$SOME-PATH$/uMessagesConst.pas line 4:20 no viable alternative at character '\'

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.