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

Added the option to the command line to set the number of extra lines in code snippets #1029

Merged

Conversation

JustMisha
Copy link

Type: feature
Breaking change: no

Instead of the magic number "2" in the renderReport method in the HTMLRenderer class, the protected field extraLineInExcerpt has been added, which is 2 by default and can be set using the --extra-line-in-excerpt command line argument.

@AJenbo
Copy link
Member

AJenbo commented Sep 13, 2023

I think you need to adjust the tests:


ArgumentCountError: Too few arguments to function PHPMD\Renderer\HTMLRenderer::__construct(), 0 passed in C:\projects\phpmd\src\test\php\PHPMD\Renderer\HTMLRendererTest.php on line 52 and exactly 1 expected
C:\projects\phpmd\src\main\php\PHPMD\Renderer\HTMLRenderer.php:73
C:\projects\phpmd\src\test\php\PHPMD\Renderer\HTMLRendererTest.php:52
phpvfscomposer://C:\projects\phpmd\vendor\phpunit\phpunit\phpunit:51

@JustMisha
Copy link
Author

Not to change the tests, made the $extraLineInExcerpt argument optional in the __constructor. This seems to make more sense.

@codecov
Copy link

codecov bot commented Sep 13, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.02% 🎉

Comparison is base (63ca48a) 92.37% compared to head (c4484f1) 92.39%.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1029      +/-   ##
============================================
+ Coverage     92.37%   92.39%   +0.02%     
- Complexity     1215     1220       +5     
============================================
  Files           110      110              
  Lines          3331     3342      +11     
============================================
+ Hits           3077     3088      +11     
  Misses          254      254              
Files Changed Coverage Δ
src/main/php/PHPMD/Renderer/HTMLRenderer.php 87.68% <100.00%> (+0.36%) ⬆️
src/main/php/PHPMD/TextUI/CommandLineOptions.php 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tvbeek
Copy link
Member

tvbeek commented Sep 15, 2023

@JustMisha Thanks for this PR, this is a nice addition. And with using an optional parameter in the constructor you also catch any BC like option of someone use the class on a not suspected way.

@tvbeek tvbeek merged commit 86c76e4 into phpmd:master Sep 15, 2023
31 checks passed
@ravage84 ravage84 added this to the 2.x (unspecific) milestone May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants