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
Merged

Make the cyclomatic complexity limit configurable. #190

merged 6 commits into from
Jun 20, 2019

Conversation

tvbeek
Copy link
Contributor

@tvbeek tvbeek 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.

Copy link
Owner

@nunomaduro nunomaduro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@tvbeek
Copy link
Contributor Author

tvbeek commented Jun 19, 2019

Good idea, I have changed it.

Copy link
Owner

@nunomaduro nunomaduro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@tvbeek
Copy link
Contributor Author

tvbeek commented Jun 19, 2019

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

@tvbeek
Copy link
Contributor Author

tvbeek commented Jun 19, 2019

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

Copy link
Collaborator

@olivernybroe olivernybroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for the contribution!

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

@Jibbarth
Copy link
Collaborator

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
Copy link
Contributor Author

tvbeek 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
Copy link
Contributor Author

tvbeek commented Jun 20, 2019

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

Copy link
Collaborator

@olivernybroe olivernybroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work!

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

@olivernybroe
Copy link
Collaborator

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

@olivernybroe olivernybroe added the enhancement New feature or request label Jun 20, 2019
docs/insights/complexity.md Outdated Show resolved Hide resolved
src/Domain/Insights/CyclomaticComplexityIsHigh.php Outdated Show resolved Hide resolved
…n and update the documentation so that the configuration is visible.

Thanks @Jibbarth for the feedback.
Copy link
Collaborator

@Jibbarth Jibbarth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌 Perfect

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

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

@nunomaduro
Copy link
Owner

Thanks @tvbeek for this pull request.

@Jibbarth Jibbarth mentioned this pull request Jun 20, 2019
7 tasks
@tvbeek tvbeek deleted the add_option_to_change_the_cyclomatic_complexity_limit branch June 20, 2019 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants