jbenden / vscode-c-cpp-flylint

A VS Code extension for advanced, modern, static analysis of C/C++ that supports a number of back-end analyzer programs.
MIT License
152 stars 29 forks source link

C/C++ FlyLint version 1.12.0: Line could not be parsed: Error: encoding error while validating #173

Closed burstchao closed 1 year ago

burstchao commented 1 year ago

my os is windows11;and when i use C/C++ FlyLint version 1.12.0 it make a error: lease analyze the 'C/C++ FlyLint' Output console. Stacktrace: Error: Line could not be parsed: Error: encoding error in g:\xxx\xxxx.cpp at c:\Users\Charles.vscode\extensions\jbenden.c-cpp-flylint-1.12.0\server\out\server.js:2:39162 at Array.forEach () at s.parseLines (c:\Users\Charles.vscode\extensions\jbenden.c-cpp-flylint-1.12.0\server\out\server.js:2:38911) at s.lint (c:\Users\Charles.vscode\extensions\jbenden.c-cpp-flylint-1.12.0\server\out\server.js:2:38814) at c:\Users\Charles.vscode\extensions\jbenden.c-cpp-flylint-1.12.0\server\out\server.js:2:48378 at Array.forEach () at L (c:\Users\Charles.vscode\extensions\jbenden.c-cpp-flylint-1.12.0\server\out\server.js:2:48353) at async c:\Users\Charles.vscode\extensions\jbenden.c-cpp-flylint-1.12.0\server\out\server.js:2:51467

burstchao commented 1 year ago

i found it will be error when i enable FlawFinder or lizard

rei-vilo commented 1 year ago

Same issue here, when CppCheck and lizard are enabled.

jbenden commented 1 year ago

Hi,

The problem is most certainly that your machine is NOT in a UTF-8 locale. I'd suggest ensuring it so Python operates in UTF-8 mode.

There is no perfect solution to the problem, either. I could possibly add a hack to "attempt" native locale, but even that could fail.... :shrug:

Best regards, -Joe

burstchao commented 1 year ago

image

my Python operates is in UTF-8 mode,but my machine file save encode mode I can`t not sure

rei-vilo commented 1 year ago

The problem is most certainly that your machine is NOT in a UTF-8 locale. I'd suggest ensuring it so Python operates in UTF-8 mode.

Thank you for the pointer.

It happens both python2 and python3 were installed on my PC. python2 was configured with ascii and python3 with UTF-8 as reported by sys.getdefaultencoding().

Setting python3 as default removed the issue.

So the case is solved for me.

burstchao commented 1 year ago

The problem is most certainly that your machine is NOT in a UTF-8 locale. I'd suggest ensuring it so Python operates in UTF-8 mode.

Thank you for the pointer.

It happens both python2 and python3 were installed on my PC. python2 was configured with ascii and python3 with UTF-8 as reported by sys.getdefaultencoding().

Setting python3 as default removed the issue.

So the case is solved for me.

my pc just install python3,it make me confused

pnrao commented 1 year ago

I had this problem too. Seeing lizard mentioned above, I checked my computer and found out that lizard was not running properly.

Running these two commands (in zsh) fixed it for me.

$ for i in `pip list -u --user --format json|jq '.[].name' -r` ; { pip install --user -U $i }

$ pip install --user lizard

Just the first command should have fixed it, but I don't know why, the second command was needed too.

@jbenden Could you make the script indicate which external tool fails, so that users can suss out which tool to fix?

romanholidaypancakes commented 1 year ago

same problem

'Line could not be parsed: cppcheck: '--enable=information' will no longer implicitly enable 'missingInclude' starting with 2.16. Please enable it explicitly if you require it.' while validating: d:xxxxxxxxxxx.cpp. Please analyze the 'C/C++ FlyLint' Output console. Stacktrace: Error: Line could not be parsed: cppcheck: '--enable=information' will no longer implicitly enable 'missingInclude' starting with 2.16. Please enable it explicitly if you require it. at c:\Users\asdafag.vscode\extensions\jbenden.c-cpp-flylint-1.13.0\server\out\server.js:2:12688 at Array.forEach () at a.parseLines (c:\Users\asdafag.vscode\extensions\jbenden.c-cpp-flylint-1.13.0\server\out\server.js:2:12437) at a.lint (c:\Users\asdafag.vscode\extensions\jbenden.c-cpp-flylint-1.13.0\server\out\server.js:2:12340) at c:\Users\asdafag.vscode\extensions\jbenden.c-cpp-flylint-1.13.0\server\out\server.js:2:21824 at Arra...

where.exe python
C:\Program Files\Python310\python.exe
python
Python 3.10.7 (tags/v3.10.7:6cc6b13, Sep  5 2022, 14:08:36) [MSC v.1933 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.getdefaultencoding()
'utf-8'
>>>