How to scan phtml and embedded javascript files in SonarQube?

1.3k views Asked by At

I did sonarqube analysis on DemoProject. I am having phtml and embedded files in it.

  1. How to scan PHTML files?

  2. PHTML files contains some Javascript code. Can we scan this javascript code?

  3. Can anyone suggest a solution for this?

  4. Is there any plugins available for the same?

Note:- I already installed javascript plugin and web plugin

2

There are 2 answers

0
Abhijeet Kamble On

For Scanning phtml files, Please install PHP plugin, PHP plugin within SonarQube supports scanning of phtml files.

Please find below the screenshot for the same.

This screeenshot shows default extension supported by SonarQube(PHP) Plugin

Please go to settings->PHP where you can see this settings.

if you want to specify the same in project properties file, you have to add following the key

sonar.php.file.suffixes= file extensions

Answering you other question of embedded code analysis. This is not supported by SonarQube. It identifies the file extension and then scan for the same.

0
Kuldeep Darmwal On

In Sonar no dedicated PHTML plugin but WEB plugin for html and PHP plugins are used to analyse these files. install PHP and WEB plugin and try sonar analysis again.