notskm / vscode-clang-tidy

MIT License
49 stars 25 forks source link

PROBLEMS's window is empty but there is DiagnosticMessage in OUTPUTS #26

Closed mumin16 closed 4 years ago

mumin16 commented 4 years ago

image: https://ibb.co/3k6t7Xn

source code:

include iomanip

include ctime

include iostream

auto main() -> decltype(0) { return 0; }

settings.json:

{

"cmake.copyCompileCommands": "${workspaceFolder}/compile_commands.json",

"clang-tidy.compilerArgsBefore":["-Wall","-Wextra","-Wpedantic","-Wunreachable-code","-Wunused-variable"],
"clang-tidy.checks": ["*"]

}
mtib commented 4 years ago

Same problem here code: 1.45.1

settings.json:

{
    "clang-tidy": {
        "buildPath": "build",
        "lintOnSave": true,
        "checks": [
            "*"
        ],
    },
    "editor.formatOnSave": true,
}

compile_commands.json created with bear. Tried both "buildPath": "build" and "build/compile_commands.json" with identical result.

It found quite a lot of errors, so I'll append the tail of Clang-Tidy's Output here:

<path>/src/demo.c:54:19: warning: variable 'res' is not initialized [cppcoreguidelines-init-variables]
            void* res;
                  ^
                      = NULL
---
MainSourceFile:  '<path>/src/demo.c'
Diagnostics:
  - DiagnosticName:  readability-else-after-return
    DiagnosticMessage:
      Message:         'do not use ''else'' after ''return'''
      FilePath:        '../src/demo.c'
      FileOffset:      483
      Replacements:
        - FilePath:        '../src/demo.c'
          Offset:          483
          Length:          5
          ReplacementText: ''
        - FilePath:        '../src/demo.c'
          Offset:          488
          Length:          36
          ReplacementText: '        for (;;) {

        }

   '
  - DiagnosticName:  cppcoreguidelines-avoid-magic-numbers
    DiagnosticMessage:
      Message:         '8 is a magic number; consider replacing it with a named constant'
      FilePath:        '../src/demo.c'
      FileOffset:      598
      Replacements:    []
  - DiagnosticName:  readability-magic-numbers
    DiagnosticMessage:
      Message:         '8 is a magic number; consider replacing it with a named constant'
      FilePath:        '../src/demo.c'
      FileOffset:      598
      Replacements:    []
  - DiagnosticName:  cppcoreguidelines-avoid-magic-numbers
    DiagnosticMessage:
      Message:         '8 is a magic number; consider replacing it with a named constant'
      FilePath:        '../src/demo.c'
      FileOffset:      637
      Replacements:    []
  - DiagnosticName:  readability-magic-numbers
    DiagnosticMessage:
      Message:         '8 is a magic number; consider replacing it with a named constant'
      FilePath:        '../src/demo.c'
      FileOffset:      637
      Replacements:    []
  - DiagnosticName:  cppcoreguidelines-avoid-magic-numbers
    DiagnosticMessage:
      Message:         '8 is a magic number; consider replacing it with a named constant'
      FilePath:        '../src/demo.c'
      FileOffset:      860
      Replacements:    []
  - DiagnosticName:  readability-magic-numbers
    DiagnosticMessage:
      Message:         '8 is a magic number; consider replacing it with a named constant'
      FilePath:        '../src/demo.c'
      FileOffset:      860
      Replacements:    []
  - DiagnosticName:  cppcoreguidelines-init-variables
    DiagnosticMessage:
      Message:         'variable ''res'' is not initialized'
      FilePath:        '../src/demo.c'
      FileOffset:      938
      Replacements:
        - FilePath:        '../src/demo.c'
          Offset:          941
          Length:          0
          ReplacementText: ' = NULL'
...

79 warnings generated.
Suppressed 71 warnings (71 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.

> clang-tidy <path>/src/main.c --export-fixes=- --checks=* -p=build
Working Directory: <path>/src/main.c:6:5: error: use of undeclared identifier 'prin' [clang-diagnostic-error]
    prin tf("Main is running!\n");
    ^
---
MainSourceFile:  '<path>/src/main.c'
Diagnostics:
  - DiagnosticName:  clang-diagnostic-error
    DiagnosticMessage:
      Message:         'use of undeclared identifier ''prin'''
      FilePath:        '../src/main.c'
      FileOffset:      75
      Replacements:    []
...

22 warnings and 1 error generated.
Error while processing <path>/src/main.c.
Suppressed 22 warnings (22 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
Found compiler error(s).
notskm commented 4 years ago

I was able to reproduce this issue. I'll be taking a closer look at it on Monday.

notskm commented 4 years ago

36 should have fixed this. Try out version 0.5.1.

stephendouglasuk commented 3 years ago

I'm still seeing this as an issue. Running 0.5.1.