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

Make the cyclomatic complexity limit configurable. #190

Merged
merged 6 commits into from Jun 20, 2019

Conversation

@tvbeek
Copy link
Contributor

commented Jun 19, 2019

Q A
Bug fix? no
New feature? yes
Fixed tickets no

I found that I wanted to change the limit of the cyclomatic complexity insight. Currently this is hard coded fixed on 5. So with this PR I add the option to change it.

@nunomaduro
Copy link
Owner

left a comment

It's perfect, I would just rename limit to maxComplexity. What do you think?

@tvbeek

This comment has been minimized.

Copy link
Contributor Author

commented Jun 19, 2019

Good idea, I have changed it.

@nunomaduro
Copy link
Owner

left a comment

@tvbeek Can you run composer test locally? Tests are not passing.

@tvbeek

This comment has been minimized.

Copy link
Contributor Author

commented Jun 19, 2019

Yes, sorry I just saw it. Currently working on it.

@tvbeek

This comment has been minimized.

Copy link
Contributor Author

commented Jun 19, 2019

It passed the test, do you have anything else that you like to have changed?

@olivernybroe
Copy link
Collaborator

left a comment

Looks great, thanks for the contribution!

If it's not too much trouble could you add a test for it? :)

@Jibbarth

This comment has been minimized.

Copy link
Collaborator

commented Jun 19, 2019

Great addition 👍 Thank you @tvbeek 🙏

If you can, can you also update documentation to help users to know how to configure it ?

You just have to add in https://github.com/nunomaduro/phpinsights/blob/master/docs/insights/complexity.md something like

+ <details>
+     <summary>Configuration</summary>
+
+ ```php
+ \NunoMaduro\PhpInsights\Domain\Insights\CyclomaticComplexityIsHigh::class => [
+     'maxComplexity' => 5
+ ]
+ ```
+ </details>

after Insight Class: NunoMaduro\PhpInsights\Domain\Insights\CyclomaticComplexityIsHigh

@tvbeek

This comment has been minimized.

Copy link
Contributor Author

commented Jun 19, 2019

@olivernybroe There wasn't a test for this insight but I will create it.

@Jibbarth thanks for pointing out to the documentation. I have added it.

@tvbeek

This comment has been minimized.

Copy link
Contributor Author

commented Jun 20, 2019

I have added a test for the CyclomaticComplexityIsHigh Insight that test this config (and the normal behavior)

@olivernybroe
Copy link
Collaborator

left a comment

Amazing work!

This PR has everything.
Tests, docs and a nice contribution 🎉

@olivernybroe

This comment has been minimized.

Copy link
Collaborator

commented Jun 20, 2019

@nunomaduro @Jibbarth I'll say this is ready for merge. So if one of you agree with me, just merge it in :)

Show resolved Hide resolved docs/insights/complexity.md Outdated
Show resolved Hide resolved src/Domain/Insights/CyclomaticComplexityIsHigh.php Outdated
Use the sprintf function to add the variables in the getTitle functio…
…n and update the documentation so that the configuration is visible.

Thanks @Jibbarth for the feedback.
@Jibbarth
Copy link
Collaborator

left a comment

👌 Perfect

@Jibbarth Jibbarth merged commit 3fdee8d into nunomaduro:master Jun 20, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@nunomaduro

This comment has been minimized.

Copy link
Owner

commented Jun 20, 2019

@Jibbarth @olivernybroe Tonight I will release a new version of php insights.

@nunomaduro

This comment has been minimized.

Copy link
Owner

commented Jun 20, 2019

Thanks @tvbeek for this pull request.

@Jibbarth Jibbarth referenced this pull request Jun 20, 2019

Closed

[internal] Release 1.7.0 ? #191

7 of 7 tasks complete

@tvbeek tvbeek deleted the TJVB:add_option_to_change_the_cyclomatic_complexity_limit branch Jun 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.