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

NPath for empty block is 1 #4045

Closed
romani opened this Issue Mar 18, 2017 · 1 comment

Comments

Projects
None yet
1 participant
@romani
Member

romani commented Mar 18, 2017

What is a Npath for empty block {} ?

http://checkstyle.sourceforge.net/config_metrics.html#NPathComplexity

if ([expr]) { [if-range] }                       => NP(if-range) + 1 + NP(expr)
if ([expr]) { [if-range] } esle { [else-range] } => NP(if-range) + NP(else-range) + NP(expr)
// (if-range=1) + 1 + (expr=1) = 3
if (true || true) { smtht(); } 

// (if-range=1) + (else-range=1) + (expr=1) = 3
if (true || true) { smtht(); } esle {}

else-range can not be 0, as it will meant that NPath become less if else is added.
so it mean that NPath of {} is 1

// (if-range=1) + (else-range=1) + (expr=1) = 3
if (true || true) { } esle {}

so

// (if-range=1) + (else-range=1) + (expr=1) = 3
if (true || true) { dosmth1(); dosmth2(); } esle { dosmth3(); }

@romani romani added the approved label Mar 18, 2017

romani added a commit that referenced this issue Mar 18, 2017

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Mar 18, 2017

Member

xdoc is extended but real fix in code will be in scope of #56 .

Member

romani commented Mar 18, 2017

xdoc is extended but real fix in code will be in scope of #56 .

@romani romani closed this Mar 18, 2017

@romani romani added this to the 7.7 milestone Mar 18, 2017

SergeyDzyuba added a commit to SergeyDzyuba/checkstyle that referenced this issue Mar 22, 2017

GitToasterhub added a commit to GitToasterhub/checkstyle that referenced this issue Mar 26, 2017

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