Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find composer.json when searching for psalm #3979

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ale_linters/php/psalm.vim
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ call ale#Set('php_psalm_options', '')
call ale#Set('php_psalm_use_global', get(g:, 'ale_use_global_executables', 0))

function! ale_linters#php#psalm#GetProjectRoot(buffer) abort
let l:composer_path = ale#path#FindNearestFile(a:buffer, 'composer.json')

if (!empty(l:composer_path))
return fnamemodify(l:composer_path, ':h')
endif

let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git')

return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : ''
Expand Down
5 changes: 5 additions & 0 deletions test/linter/test_psalm.vader
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ Execute(User provided options should be used):
AssertLinter 'psalm',
\ ale#Escape('psalm')
\ . ' --language-server --my-user-provided-option my-value'

Execute(The project path should be correct for composer.json file):
call ale#test#SetFilename('../test-files/php/with-composer/test.php')

AssertLSPProject ale#path#Simplify(g:dir . '/../test-files/php/with-composer')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using AssertLSPProject here but not sure if this is the best way to test this case.
I'll be more than happy to be corrected ;)