Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Design Guidelines #1652

Closed
guwirth opened this issue Jan 3, 2019 · 5 comments
Closed

Design Guidelines #1652

guwirth opened this issue Jan 3, 2019 · 5 comments
Assignees
Milestone

Comments

@guwirth
Copy link
Collaborator

guwirth commented Jan 3, 2019

@ivangalkin @Bertk @jmecosta
Please review and complete: https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Design-Guidelines

Like to finish this before we continue with #1638 & #1650.

@ivangalkin
Copy link
Contributor

Hi @guwirth,

I really like the guidelines. Some minor comments from my side:

The plugin expects to be fed with syntactically correct code. This is a conscious design decision: we do not want to reimplement a compiler.

The first sentence goes in the right direction. The wording of the 2nd sentence is not clear to me. We obviously reimplement a parser (preprocessor + lexer + the language grammar). So what you probably mean is something like: We don't aim to check syntax/semantic by means of our parser. Parsing errors shouldn't be reported as technical debt in terms of SonarQube. Am I right?

erroneous reports; we support a tolerant and strict error handling mode (sonar.cxx.errorRecoveryEnabled)

AFAIK we don't have such feature for the external reports (yet). For the external reports we run in the (hardcoded) strict mode. W.r.t. the source code parsing we run in the tolerant mode by default. I like these defaults - it's easy to parse the external reports, so the strict mode makes sense here. Parsing of the source code is hard, so we should be tolerant to [our own] parsing errors.

In my opinion it would be wrong to overload the property sonar.cxx.errorRecoveryEnabled. For external reports I think we need an extra flag. Something like sonar.cxx.importErrorRecoveryEnabled or such.

Minor: I am not relay sure about the word "tolerant" ("strict mode" vs "tolerant mode"). I would prefer something like "relaxed mode" or "continue-on-error mode" or something better. But that's a matter of taste.

@guwirth
Copy link
Collaborator Author

guwirth commented Jan 4, 2019

@ivangalkin

The wording of the 2nd sentence is not clear to me

Think parser and compiler are not the same thing. We read tokens, match it against a grammar and create an AST. We do for example no semantic analysis. The sentence should express somehow that our goal is not to implement a C++ syntax or semantic checker. This is what a compiler is already doing. We also don’t like to create syntax and semantic errors and warnings. This is also what compilers are already doing.

AFAIK we don't have such feature for the external reports

Most sensors are using CxxUtils.validateRecovery
https://github.com/SonarOpenCommunity/sonar-cxx/blob/master/cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/CxxUtils.java#L84

@guwirth
Copy link
Collaborator Author

guwirth commented Jan 4, 2019

@ivangalkin

Better?

  • the plugin expects to be fed with syntactically correct code
    • use an external compiler to get detailed syntax and semantic issues

@guwirth
Copy link
Collaborator Author

guwirth commented Jan 4, 2019

@ivangalkin

In my opinion it would be wrong to overload the property sonar.cxx.errorRecoveryEnabled

Thinking about this the question is if we need a flag for the source code? For source code it should always be errorRecoveryEnabled=True. Remove the other case.
https://github.com/SonarOpenCommunity/sonar-cxx/blob/master/cxx-squid/src/main/java/org/sonar/cxx/parser/CxxGrammarImpl.java#L402

@ivangalkin
Copy link
Contributor

@guwirth

Better?

yes, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants