Giter Club home page Giter Club logo

sonardelphi's Introduction

Build Status

SonarQube Delphi

Is a SonarQube (http://www.sonarqube.org/) plugin and provides

  • 49 Rules for Delphi
  • TestCoverage using AQtime (license needed)
  • Optional .html output for TestCoverage

This is Plugin-Version 3.4 SonarQube 5.6.1(LTS) is needed. It is is mainly an updated version of https://github.com/fabriciocolombo/sonar-delphi all credit goes to them. I have hosted it here since the orignal developer isn't active anymore.

This plugin was originally a Sabre Airline Solutions donation.

License

The entire PLugin follows the GPL: https://github.com/SandroLuck/SonarDelphi/blob/master/src/LUCK_LICENSE.txt

Steps to Analyze a Delphi Project

  1. Install SonarQube Server (see Setup and Upgrade for more details). Check supported versions of the latest release of the plugin.
  2. Install one of the supported Runners (see below) and be sure you can call it from the directory where you have your source code
  3. Install Delphi Plugin (see Installing a Plugin for more details). NOTE: This only applies to SonarQube 5.6.1(LTS) and heigher. For older versions see Delphi Plugin
  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.
  5. Run your Analyzer command from the project root dir
  6. Follow the link provided at the end of the analysis to browse your project's quality in SonarQube UI (see: Browsing SonarQube)

Supported Runners

To run an analysis of your Java project, you can use the following Runners:

Reporting Issues

SonarQube Delphi Plugin uses GitHub's integrated issue tracking system to record bugs and feature requests. If you want to raise an issue, please follow the recommendations below:

  • Before you log a bug, please search the issue tracker to see if someone has already reported the problem.
  • If the issue doesn't already exist, create a new issue
  • Please provide as much information as possible with the issue report, we like to know the version of SonarQube Delphi Plugin that you are using, as well as the SonarQube version.
  • If possible try to create a test-case or project that replicates the issue.

Implemented Features

  • Counting lines of code, statements, number of files
  • Counting number of classes, number of packages, methods, accessors
  • Counting number of public API (methods, classes and fields)
  • Counting comments ratio, comment lines (including blank lines)
  • CPD (code duplication, how many lines, block and in how many files)
  • Code Complexity (per method, class, file; complexity distribution over methods, classes and files)
  • LCOM4 and RFC
  • Code colorization
  • Assembler syntax in grammar
  • Include statement
  • Parsing preprocessor statements
  • Rules
  • Tagable Issues
  • "Dead" code recognition
  • Unused files recognition
  • Unused functions
  • Unused procedures (Optional with AQtime)
    • Coverage using AQtime
    • Sufficient Coverage on new Code

Code Assumptions

  • 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)
  • Number of classes includes: classes, records
  • Directory is count as a package. Number of packages equals number of directories.
  • Preprocessor definitions between {$if xxx} and {$ifend} are removed (DefineResolver class).
  • 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.

CodeCoverage

I am very sorry but I can't release the CodeCoverage solution I used so if you want CodeCoverage please refer to latest release

Importing into Eclipse

First run the eclipse maven goal:

mvn eclipse:eclipse

The project can then be imported into Eclipse using File -> Import and then selecting General -> Existing Projects into Workspace.

Importing into Intellij

Simply open the pom.xml in Intellij should solve most dependecies by itself.

sonardelphi's People

Contributors

sandroluck 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

Watchers

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

sonardelphi's Issues

Unused functions

Source.zip

Hello,

There is something wrong with metric "Unused functions".
I have declarated global function F2 in unit u1 and I used this function in unit2 but Sonar says that the function is not used :(

The same situation occurs when I don't add () at the end of the function call.

example in attachment

best regards
Jarek
screen1

Code duplication

I think that the "uses" block should never be marked as a duplicate.
It often happens that two units have the same this block and it is not a mistake.

screen2

Sonarqube 6.2 Support

Hello Sandroluck,
I was wondering if you had any plans to update your fork of the project to support Sonarqube 6.2. We just set Sonarqube up and are trying to decide whether to downgrade to the LTS, or possibly fork the project and try to update it.

CodeCoverageSensor is missing

Thank you for upgrading to Sonar 5.6.1! Basic feature are working fine.

I don't get unit test reporting and code coverage reporting to work. My CodeCoverage_Summary.xml is ignored and unit test report processing fails with exception:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.2:sonar (default-cli) on project win32client: org.sonar.plugins.surefire.data.SurefireStaxHandler cannot be ast to org.sonar.api.utils.StaxParser$XmlStreamHandler at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) 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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) Caused by: org.apache.maven.plugin.MojoExecutionException: org.sonar.plugins.surefire.data.SurefireStaxHandler cannot be cast to org.sonar.api.utils.StaxParser$XmlStreamHandler at org.sonarsource.scanner.maven.bootstrap.ExceptionHandling.handle(ExceptionHandling.java:36) at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(ScannerBootstrapper.java:81) at org.sonarsource.scanner.maven.SonarQubeMojo.execute(SonarQubeMojo.java:112) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ... 19 more Caused by: java.lang.ClassCastException: org.sonar.plugins.surefire.data.SurefireStaxHandler cannot be cast to org.sonar.api.utils.StaxParser$XmlStreamHandler at org.sonar.plugins.delphi.surefire.DelphiSureFireParser.parseFiles(DelphiSureFireParser.java:124) at org.sonar.plugins.delphi.surefire.DelphiSureFireParser.parseFiles(DelphiSureFireParser.java:117) at org.sonar.plugins.delphi.surefire.DelphiSureFireParser.collect(DelphiSureFireParser.java:87) at org.sonar.plugins.delphi.surefire.SurefireSensor.collect(SurefireSensor.java:93) at org.sonar.plugins.delphi.surefire.SurefireSensor.analyse(SurefireSensor.java:86) 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(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60) at com.sun.proxy.$Proxy16.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.maven.bootstrap.ScannerBootstrapper.execute(ScannerBootstrapper.java:78) ... 22 more

My pom.xml:
<properties> <sonar.language>delph</sonar.language> <sonar.junit.reportsPath>test-report</sonar.junit.reportsPath> <sonar.delphi.codecoverage.tool>delphi code coverage</sonar.delphi.codecoverage.tool> <sonar.delphi.codecoverage.report>target\CodeCoverage_Summary.xml</sonar.delphi.codecoverage.report> <sonar.emma.reportPath>target\CodeCoverage_Summary.xml</sonar.emma.reportPath> <sonar.importSources>true</sonar.importSources> </properties>

I'm using Sonar 5.6.1 LTS and Java 8. Delphi 10.1 and CodeCoverageTool 1.0 RC.

Do you have any ideas?

Stack Overflow Error when running on bigger projects

Hey there,

I am experiencing random StackOverflowError exceptions on my projects, when I use the plugin.

The output on the sonar-scanner:
image

I am running SonarQube server 5.6.3 with the latest jar from your releases.

So far, only using exclusions is helping to reduce the amount of code analyzed, which is not satisfying at all.

Is there any workaround for this issue?

Harald

Recursive generic definitions are not handled well

This does work properly:
TGenericC<T> = class(TNonGeneric, IGeneric<T>);
TGenericC<T> = class(TGeneric<T>, INonGeneric);
TGenericC<T> = class(TGeneric<T, R>, IGeneric<T, R>);

And this doesn't:
TGenericC<T> = class(TNonGeneric, IGeneric<IList<T>>);
TGenericC<T> = class(TGeneric<IList<T>>, INonGeneric);
TGenericC<T> = class(TGeneric<IList<T>, R>, IGeneric<R, IList<T>>)

Sonar fails to start with NoClassDefFoundError

I have Sonar 6.7.3 on Windows 2016. I downloaded the release 0.3.4-beta but also the latest sources and compiled it. I put the jar in the download directory, restart Sonar. Sonar gives a stack trace and fails to start.

Can someone help?

Stacktrace:
java.lang.IllegalStateException: Fail to load plugin Delphi [delphi]
at org.sonar.server.plugins.ServerExtensionInstaller.installExtensions(ServerExtensionInstaller.java:88)
at org.sonar.server.platform.platformlevel.PlatformLevel4.start(PlatformLevel4.java:582)
at org.sonar.server.platform.Platform.start(Platform.java:211)
at org.sonar.server.platform.Platform.startLevel34Containers(Platform.java:185)
at org.sonar.server.platform.Platform.access$500(Platform.java:46)
at org.sonar.server.platform.Platform$1.lambda$doRun$0(Platform.java:119)
at org.sonar.server.platform.Platform$AutoStarterRunnable.runIfNotAborted(Platform.java:371)
at org.sonar.server.platform.Platform$1.doRun(Platform.java:119)
at org.sonar.server.platform.Platform$AutoStarterRunnable.run(Platform.java:355)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: org/sonar/api/web/CodeColorizerFormat
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at org.sonar.classloader.ClassRealm.loadClassFromSelf(ClassRealm.java:125)
at org.sonar.classloader.ParentFirstStrategy.loadClass(ParentFirstStrategy.java:37)
at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:87)
at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:76)
at org.sonar.plugins.delphi.DelphiPlugin.getExtensions(DelphiPlugin.java:99)
at org.sonar.api.SonarPlugin.define(SonarPlugin.java:51)
at org.sonar.server.plugins.ServerExtensionInstaller.installExtensions(ServerExtensionInstaller.java:78)
... 9 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.sonar.api.web.CodeColorizerFormat
at org.sonar.classloader.ParentFirstStrategy.loadClass(ParentFirstStrategy.java:39)
at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:87)
at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:76)
... 25 common frames omitted
2018.06.11 09:02:17 INFO web[][o.s.p.StopWatcher] Stopping process

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.