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

Mcclure's complexity #12

Open
shaifulcse opened this issue Apr 7, 2020 · 2 comments
Open

Mcclure's complexity #12

shaifulcse opened this issue Apr 7, 2020 · 2 comments
Assignees

Comments

@shaifulcse
Copy link

shaifulcse commented Apr 7, 2020

For the code below:
The number of control variables is 7, and the number of comparisons is 4. I am wondering if that's correct. For example, SCOPE is considered only as one control variable, although it has four different values in the code. Likewise, Condition like if (mCheckDefaultMethods) is not considered as a comparison.

private void checkCounters(DetailAST aAst)
{
final MethodCounter actualCounter = mCounters.peek();
if (mCheckDefaultMethods) {
if (actualCounter.value(Scope.PACKAGE) > mMax) {
log(aAst.getLineNo(), "too.many.defaultMethods",
actualCounter.value(Scope.PACKAGE), mMax);
}
}
if (mCheckPrivateMethods) {
if (actualCounter.value(Scope.PRIVATE) > mMax) {
log(aAst.getLineNo(), "too.many.privateMethods",
actualCounter.value(Scope.PRIVATE), mMax);
}
}
if (mCheckProtectedMethods) {
if (actualCounter.value(Scope.PROTECTED) > mMax) {
log(aAst.getLineNo(), "too.many.protectedMethods",
actualCounter.value(Scope.PROTECTED), mMax);
}
}
if (mCheckPublicMethods) {
if (actualCounter.value(Scope.PUBLIC) > mMax) {
log(aAst.getLineNo(), "too.many.publicMethods",
actualCounter.value(Scope.PUBLIC), mMax);
}
}
}

@rodhilton
Copy link
Owner

Yep, seems like a bug. Thanks for reporting, I'll get to it when I can.

@rodhilton rodhilton self-assigned this Apr 7, 2020
@shaifulcse
Copy link
Author

Thanks for the reply. Also, I am confused the way you are calculating the number of comparisons. I can not find a real definition anywhere that clearly says what it is. For example, if(a>b and b<c), do we have one or two comparisons here?

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

No branches or pull requests

2 participants