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

Already on GitHub? Sign in to your account

First refactor of Report #298

merged 6 commits into from Mar 24, 2013


None yet
3 participants

barttenbrinke commented Mar 21, 2013

Because you challenged me to tackle report.rb.. here goes :

  • The initialisers have been moved to their own files
  • The renderer is now a separate object, making refactoring easier and the namespace less polluted
  • Thanks to the renderer refactor it is now possible to refactor common methods. I've refactored array rendering into a single function, cleaning up the code a lot. This saves about 25% lines of code.

This new structure opens up possibilities to do more refactoring.

barttenbrinke added some commits Mar 21, 2013

@barttenbrinke barttenbrinke Moved initialisers to separate initialiser directory 5a650b2
@barttenbrinke barttenbrinke Move renderer to separate object
 - Use locals instead of global binding
 - This opens up the possibility to clean up methods, because rendering and variables can now be seperated.
@barttenbrinke barttenbrinke Refactored array rendering into a separate function.
 - Cleaned up some ifs
 -  Inlined some functions

@presidentbeef presidentbeef and 1 other commented on an outdated diff Mar 21, 2013

@@ -0,0 +1,9 @@
+#This is so OkJson will work with symbol values
+if mj_engine == :ok_json

presidentbeef Mar 21, 2013


How would this variable get here? I think you could combine this file with multi_json.rb


barttenbrinke Mar 21, 2013


Copy paste error :x Will fix tomorrow :)


presidentbeef commented Mar 21, 2013

Hi Bart,

Thanks for your contributions!

How do you feel about moving everything to do with reports (templates, renderer, initializers) into a report directory? I'm reluctant to add more files to the lib/brakeman/ directory.

Also, you can see this is failing on Ruby 1.8.7.

Thanks again! 💎


barttenbrinke commented Mar 22, 2013

Fixed! And Travis agrees.


presidentbeef commented Mar 22, 2013

Thanks! @oreoshake thoughts?


oreoshake commented Mar 22, 2013

MUCH better. I'd still like to see each report type in it's own class/module, but that's definitely not a blocker.



barttenbrinke commented Mar 22, 2013

I believe in doing these things in really small increments. You can't pull this from F to A, because it will affect a lot of other files in the code. I think I've removed the major issues that prevented people from cleaning it up at all (renderer & initializers), so that it can now move forward in the right direction .. it is now possible to write a report class / module that would make sense :)

@presidentbeef presidentbeef added a commit that referenced this pull request Mar 24, 2013

@presidentbeef presidentbeef Merge pull request #298 from barttenbrinke/master
Refactor of Brakeman::Report class

@presidentbeef presidentbeef merged commit d42af6c into presidentbeef:master Mar 24, 2013

1 check passed

default The Travis build passed

@presidentbeef presidentbeef locked and limited conversation to collaborators Feb 16, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.