Giter VIP home page Giter VIP logo

sonar-php's Introduction

Code Quality and Security for PHP

Cirrus CI - Task and Script Build Status Quality Gate Status Coverage Maven Central GitHub

This SonarSource project is a static code analyzer for PHP language used as an extension for the SonarQube platform. It will allow you to produce stable and easily supported Clean Code by helping you find and correct bugs, vulnerabilities, and code smells.

Features

Useful links

More documentation

Have questions or feedback?

To provide feedback (request a feature, report a bug, etc.) use the SonarSource Community Forum. Please do not forget to specify the language (PHP!), plugin version, and SonarQube version.

If you have a question on how to use plugin (and the docs don't help you), we also encourage you to use the community forum.

Contributing

Topic in SonarSource Community Forum

To request a new feature, please create a new thread in SonarSource Community Forum. Even if you plan to implement it yourself and submit it back to the community, please start a new thread first to be sure that we can follow up on it.

Pull Request (PR)

To submit a contribution, create a pull request for this repository. Please make sure that you follow our code style and that all tests are passing.

Custom Rules

If you have an idea for a rule but you are not sure that everyone needs it you can implement a custom rule available only for you.

Custom Rules API Changes

  • 3.32 (October 2023)
    • Additional newIssue endpoint added to the CheckContext API interface
  • 3.15 (January 2021)
    • PHPCustomRulesDefinition was removed, it was deprecated since version 2.13 (March 2018)
    • Removed dependency on sslr-squid-bridge which is not maintained anymore
  • 3.11, support of PHP 8:
    • ParameterTree#type() is deprecated. Use ParameterTree#declaredType() instead.
    • ReturnTypeClauseTree#type() is deprecated. Use ReturnTypeClauseTree#declaredType() instead.
    • ClassPropertyDeclarationTree#typeAnnotation() is deprecated. Use ClassPropertyDeclarationTree#declaredType() instead.
    • CatchBlockTree#variable() can now return NULL.
    • FunctionCallTree#arguments() is deprecated. Use FunctionCallTree#callArguments() instead.
    • AnonymousClassTree#arguments() is deprecated. Use AnonymousClassTree#callArguments() instead.
    • New tree: CallArgumentTree. This tree wraps expressions passed as arguments now.
    • New kind of expression: ThrowExpressionTree.
    • New kind of expression: MatchExpressionTree.
    • ParameterTree now has a visibility method.

Testing

To run tests locally follow these instructions.

Build the Project and Run Unit Tests

To build the plugin and run its unit tests, execute this command from the project's root directory (you will need Maven):

mvn clean install

Integration Tests

To run integration tests, you will need to create a properties file like the one shown below, and set its location in an environment variable named ORCHESTRATOR_CONFIG_URL.

# version of SonarQube server
sonar.runtimeVersion=9.9

Before running any of the integration tests make sure the submodules are checked out:

  git submodule init
  git submodule update

Plugin Test

The "Plugin Test" is an additional integration test that verifies plugin features such as metric calculation, coverage, etc. To launch it, execute this command from the directory its/plugin:

mvn clean install

Ruling Test

The "Ruling Test" is a special integration test that launches the analysis of a large code base, saves the issues created by the plugin in report files, and then compares those results to the set of expected issues (stored as JSON files). To launch the ruling test:

cd its/ruling
mvn clean install

This test gives you the opportunity to examine the issues created by each rule and make sure they're what you expect. You can inspect new/lost issues by checking the web pages mentioned in the logs at the end of the analysis:

INFO  - HTML Issues Report generated: /path/to/project/sonar-php/its/sources/src/.sonar/issues-report/issues-report.html
INFO  - Light HTML Issues Report generated: /path/to/project/sonar-php/its/sources/src/.sonar/issues-report/issues-report-light.html

If everything looks good to you, you can copy the file with the actual issues located at

sonar-php/its/ruling/target/actual/

into the directory with the expected issues

sonar-php/its/ruling/src/test/resources/expected/

License

Copyright 2010-2024 SonarSource.

Licensed under the GNU Lesser General Public License, Version 3.0

sonar-php's People

Contributors

akram avatar alban-auzeill avatar andrei-epure-sonarsource avatar bellingard avatar benzonico avatar christophe-zurn-sonarsource avatar ehartmann avatar fmallet avatar gaudol avatar gennadiylitvinyuk avatar godin avatar henryju avatar inverno avatar ivandalbosco avatar jonas-wielage-sonarsource avatar karim-ouerghemmi-sonarsource avatar lindamartin avatar marco-bearzi-sonarsource avatar mstachniuk avatar nils-werner-sonarsource avatar petertrr avatar pynicolas avatar renaud-tognelli-sonarsource avatar roberto-orlandi-sonarsource avatar rudy-regazzoni-sonarsource avatar saberduck avatar simonbrandhof avatar tomverin avatar vilchik-elena avatar wohops 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

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.