Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude files/folders from code inspection in PHPStorm?

Tags:

phpstorm

I have a project in PHPStorm, which contains a few libraries (Zend, Doctrine, ...) grouped under a library folder.

When running the code inspection, I do want the PHP code in these folders to be analysed (so that PHPStorm will know how Zend_Form is declared, for example).

However, I do not want the issues found in these folders to be reported, as they are out of my control.

The only workaround I've found so far is to mark the directories as "Test source", and uncheck the "Include test sources" box in the code inspection window. Needless to say that this is not the best solution!

like image 945
BenMorel Avatar asked Jun 21 '12 00:06

BenMorel


People also ask

How do I ignore a folder in IntelliJ?

You can also just right click on your folder and select Mark Directory As > Excluded . Excluded folders (shown as rootExcluded) are ones that IntelliJ IDEA "partially ignores".

What is exclude file?

If the project is a Web Site, Visual Studio excludes a file from the project by adding an extension ". exclude" to mark it as excluded. So all files will the extension ". exclude" will not be used in the project. ".

How do I ignore a folder in PyCharm?

PyCharm allows you to exclude directories from consideration when searching and refactoring. You can exclude a directory by right-clicking on it and selecting Mark Directory as → Excluded.

How do I exclude files in eclipse?

Navigate to the file/folder you want to exclude. Right Click -> Resource -> Exclude from build.


5 Answers

If you just need to disable inspections on one or two files, you can disable it at the file level easily:

  1. Open offending file
  2. Click 'Code' -> 'Configure Current File Analysis'
  3. Set slider for offending language to 'None'

(Using PHPStorm 8.0.2)

like image 159
Justin Avatar answered Oct 13 '22 04:10

Justin


Please refer to the Scopes feature. You can define a custom scope for just your code, without the library folder, then run inspections on this scope only.

In the Inspections settings it's also possible to add the scopes and enable/disable each inspection per scope.

like image 29
CrazyCoder Avatar answered Oct 13 '22 05:10

CrazyCoder


If you need to completely exclude few files from any analyse (for example a compiled php file) like it not even exist, you can right click on file in source tree and select "Mark as Plain Text". This action totally remove any inspections on this file. With this I removed a lot of notifications about "source duplications" in Laravel 5.

If you need to activate it again - once more right click and "Mark as PHP".

This works nice for a few files. If you need to exclude whole directory with everything inside, use directory marking from settings or right click on directory and "Mark Directory As -> Excluded".

like image 28
Dmitry Sichev Avatar answered Oct 13 '22 04:10

Dmitry Sichev


There is alternative solution. You can add «read-only» libraries to Include pathin Settings » PHP section.

It is not the same with php.ini include_path option, just referencing to some dirs as external, outside of your control. Exactly what you need.

As result

  • no problems with scopes defining, just inspect whole project, if needed
  • no useless version control overhead in libs
like image 30
Николай Конев Avatar answered Oct 13 '22 06:10

Николай Конев


If you want to totally exclude a file or folder from completion and code help:
Right click the folder or file in your file browser (left handed) choose "Mark"-> "excluded"

That's what I wanted, I add that answer here because I found this question in Google when looking for an answer.

like image 23
John Avatar answered Oct 13 '22 06:10

John