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

前端 未结 5 1229
轮回少年
轮回少年 2020-12-07 22:17

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

When running the code inspection, I <

相关标签:
5条回答
  • 2020-12-07 22:24

    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".

    0 讨论(0)
  • 2020-12-07 22:28

    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)

    0 讨论(0)
  • 2020-12-07 22:34

    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.

    0 讨论(0)
  • 2020-12-07 22:41

    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
    0 讨论(0)
  • 2020-12-07 22:45

    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.

    0 讨论(0)
提交回复
热议问题