Skip to content
New issue

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

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

Already on GitHub? # to your account

update Julia complexity checks #366

Merged
merged 1 commit into from
Jan 10, 2023
Merged

update Julia complexity checks #366

merged 1 commit into from
Jan 10, 2023

Conversation

stevengj
Copy link
Contributor

@stevengj stevengj commented Jan 9, 2023

The Julia complexity checks included a switch statement (which does not currently exist in Julia) but omitted elseif and try/catch/finally (unlike Python).

Also, the Julia checks oddly included two comparison operators == and !=, which are not control flow (unlike the short-circuiting && and ||), are only two of the many comparison operators in Julia, and don't seem to be used as complexity measures by scc for Python. So I deleted these two from the list. Is there a good argument for why these should be included? (I see that a number of languages, like Ruby and C++, do include them for some reason.)

I also considered adding Julia's -> and do operators which create anonymous functions, but you don't use the analogous lambda in Python so I left it out.

@boyter
Copy link
Owner

boyter commented Jan 10, 2023

If you think they are worth adding by all means add them in. Too many languages for me to be across them all.

Thanks so much for the PR though! Will be into the next release.

@boyter boyter merged commit 26b7dcb into boyter:master Jan 10, 2023
@stevengj stevengj deleted the patch-1 branch January 10, 2023 12:21
@stevengj
Copy link
Contributor Author

stevengj commented Jan 10, 2023

Thanks! (Any thoughts on why so many languages have == and != in their complexity measures? This confused me. Why only those boolean operators specifically?)

@boyter
Copy link
Owner

boyter commented Jan 11, 2023

When I added them initially, I just looked for any operation that would be a loop/branch/switch condition. Since == and != tends to result in a branch IE makes it more complex I included them.

The idea was to catch logic like

if input == MagicNumber && input != BadNumber 

Such that it would increment the count for each condition of the if since they add additional overhead to the developer.

So the following would be considered less complex

if input == 1

That was the main idea.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants