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

Add clangtidy fixer #2548

Merged
merged 5 commits into from
Jul 2, 2019
Merged

Add clangtidy fixer #2548

merged 5 commits into from
Jul 2, 2019

Conversation

ObserverOfTime
Copy link
Contributor

@ObserverOfTime ObserverOfTime commented May 31, 2019

This pull request adds a clangtidy fixer using clang-tidy -fix.
I based the tests on the clang-format tests.

Edit: force-pushed to try and fix the tests.
For some reason, the second test keeps failing with

(2/2) [EXECUTE] (X) Vim(return):E716: Key not present in Dictionary: ale_c_build_dir
      > function ale#fixers#clangtidy#Fix[2]..ale#fixers#clangtidy#GetCommand[2]..ale#c#GetBuildDirectory[8]..ale#Var, line 4

Copy link
Member

@w0rp w0rp left a comment

Choose a reason for hiding this comment

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

I just merged #2566, so the new options from there should be used. I think we should check the buffer's filetype and use the options for C++ when the buffer has the cpp filetype, and use the options for C otherwise. Update the code to cover all of that, and fix the conflicts.

endfunction

function! ale#fixers#clangtidy#Fix(buffer) abort
let l:executable = ale#fixers#clangtidy#GetExecutable(a:buffer)
Copy link
Member

Choose a reason for hiding this comment

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

Get the executable by just reading the option instead. clang-tidy isn't a Node.js script.

@ObserverOfTime
Copy link
Contributor Author

How do I adapt the ale#Set calls based on the filetype? Or should I just duplicate them?

@w0rp
Copy link
Member

w0rp commented Jun 10, 2019

You can create the keys to set like l:language . '_clangtidy_options', with l:language set to 'cpp' or defaulting to 'c'.

Also, use cpp variables in cpp filetypes
call s:set_variables()

function! ale#fixers#clangtidy#Var(buffer, name) abort
let l:ft = getbufvar(a:buffer, '&filetype')
Copy link
Member

Choose a reason for hiding this comment

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

The filetype could be a compound of 'c' and something else. I recommend instead using 'cpp' if the filetype contains 'cpp', and 'c' otherwise.

w0rp
w0rp previously approved these changes Jul 2, 2019
@w0rp w0rp merged commit 8700586 into dense-analysis:master Jul 2, 2019
@w0rp
Copy link
Member

w0rp commented Jul 2, 2019

Cheers! 🍻

timlag1305 pushed a commit to timlag1305/ale that referenced this pull request Nov 5, 2019
* Add clangtidy fixer
* Add extra_options to clangtidy fixer
* Also, use cpp variables in cpp filetypes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants