Skip to content

.travis.yml: Add *.json file validation#2362

Merged
versat merged 1 commit into
cppcheck-opensource:masterfrom
versat:json_validation
Nov 21, 2019
Merged

.travis.yml: Add *.json file validation#2362
versat merged 1 commit into
cppcheck-opensource:masterfrom
versat:json_validation

Conversation

@versat

@versat versat commented Nov 14, 2019

Copy link
Copy Markdown
Collaborator

No description provided.

@versat

versat commented Nov 14, 2019

Copy link
Copy Markdown
Collaborator Author
./naming.json:5:8: Error: Values must be separated by a comma
   |  At line 5, column 8, offset 103
   |  Array started at line 3, column 12, offset 48
./naming.json: has error

Validation works. I will add a commit fixing naming.json.

@versat

versat commented Nov 15, 2019

Copy link
Copy Markdown
Collaborator Author

After fixing naming.json Travis prints a lot of naming violations, for example

lib/importproject.h:115:11: warning: Variable ProjectElementName violates naming convention [naming-varname]
    const char ProjectElementName[] = "project";
          ^
lib/importproject.h:116:11: warning: Variable ProjectVersionAttrib violates naming convention [naming-varname]
    const char ProjectVersionAttrib[] = "version";
          ^
...

@danmar Was the error in naming.json intended? Why does Cppcheck happily parse such a file that obviously does not work? Is that intended too?
The Travis command that also checks for naming violations is in line 216.

@danmar

danmar commented Nov 15, 2019

Copy link
Copy Markdown
Collaborator

the error in naming.json was not intended.

Why does Cppcheck happily parse such a file that obviously does not work? Is that intended too?

why shouldn't it parse that file?

@versat

versat commented Nov 16, 2019

Copy link
Copy Markdown
Collaborator Author

why shouldn't it parse that file?

What I mean is that I wonder if Cppcheck should better exit with an error message if a. json file is erroneous instead of using only some part of the .json without any warning.
I would expect a program to issue an error message and exit with an error code if an input file is invalid. This gives the user the chance to detect and fix the error instead of getting wrong results without knowing that they are wrong.

Maybe picojson has the functionality to detect errors. I can see if we can use that.
I suggest to first fix it inside Cppcheck and only then add the external json validation from this PR.

@danmar

danmar commented Nov 16, 2019

Copy link
Copy Markdown
Collaborator

I would expect a program to issue an error message and exit with an error code if an input file is invalid.

I agree!

@amai2012

Copy link
Copy Markdown
Collaborator

Should this be merged now?

@versat

versat commented Nov 21, 2019

Copy link
Copy Markdown
Collaborator Author

Should this be merged now?

Yes, thanks for reminding me.

@versat versat merged commit cc34fee into cppcheck-opensource:master Nov 21, 2019
@versat versat deleted the json_validation branch November 21, 2019 08:12
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