apache / apache/nuttx

nxstyle: Suppress checking in strings/comments.

Open
#387 0 comments 0 reactions 0 assignees View on GitHub
Type: Bug
Dominant language
C
Stars
4k
Forks
1.7k
Avg merge
1d 17h
Merged PRs (30d)
237

Description

nxstyle does not detect when it is within a string and will report crazy things because it is parsing the strng content. For example, if the string contains "Hello", nxstyle would probleam complain about mixed case identifiers, if the strong contains "https://", it would probably complete about C++ style comments. If the string contains "yes/no" it would probably complain about missing spaces before and after an operator.

Below is a even more obsure false alarm example:

junk.c:

/****************************************************************************
* Private Data
****************************************************************************/

static const char g_blabber[] = "Yadda, yadda, yadda, yadda";

/****************************************************************************
* Public Functions
****************************************************************************/

then you see:

$ tools/nxstyle.exe junk.c
junk.c:5:39: error: Multiple data definitions

In this case, nxstyle should ignore the ',' characters is within a string.

Most of this also applies to comments. You will see the same kinds of errors for similer sub-strings within a comment. nxstyle does detect that it is within a comment, however, it does not use that information to suppress certain error reports.

Contributor guide

Open the contributing guide

Research direction

Start with the nxstyle implementation used by tools/nxstyle.exe and reproduce the reported diagnostics with junk.c, including strings and comments containing punctuation or identifier-like text. Trace how the tool identifies strings and comments, then verify that checks are suppressed inside them while normal code is still diagnosed without the listed false alarms.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.