notskm / vscode-clang-tidy

MIT License
49 stars 25 forks source link

Problems found in included headers show at the wrong position in .cpp compilation unit. #11

Open dpar39 opened 4 years ago

dpar39 commented 4 years ago

I think what's happening is that issues found in .h files included in the compilation unit are being shown in .cpp file at the .h FileOffset. Would it be difficult to move the "problems" to the header files so that are shown in it when viewed? By the way, thanks for the VSCode extension. I think what you are targeting with it is the main thing holding VScode to be the best free C++ IDE available.

 - DiagnosticName:  readability-inconsistent-declaration-parameter-name
    Message:         'function ''MyClass::myMethod()'' has a definition with different parameter names'
    FileOffset:      23691
    FilePath:        '/Code/MyClass.h'
    Notes:           
      - Message:         the definition seen here
        FilePath:        '/Code/MyClass.cpp'
        FileOffset:      93200
      - Message:         'differing parameters are named here: (''links''), in definition: (''groups'')'
        FilePath:        '/Code/MyClass.h'
        FileOffset:      23691
    Replacements:    
      - FilePath:        '/Code/MyClass.h'
        Offset:          23760
        Length:          5
        ReplacementText: groups
notskm commented 4 years ago

I think I ran into this while working on a project the other day. I'll look into it soon, hopefully.

At first glance, it shouldn't take too long to fix, but I haven't looked at this extension in a while. It may take longer than I expect.

makemeunsee commented 4 years ago

adding if (diagnosticMessage.FilePath == tidyResults.MainSourceFile) { on line 168 of tidy.ts filters out the diagnostics which are not relevant to the current file. I guess they could be filtered out earlier actually; I havent looked enough to see if they actually serve a purpose.

notskm commented 4 years ago

I believe this is fixed by #30. However, it does mean that warnings that would be displayed incorrectly are no longer being displayed at all. Before I fix this issue, I'd like to do a lot of refactoring. I'm going to defer this until after the next release. That should be Friday.