code_metric_fu 4.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +28 -0
  3. data/.metrics +3 -0
  4. data/.rspec +2 -0
  5. data/.rubocop.yml +15 -0
  6. data/.rubocop_todo.yml +69 -0
  7. data/.simplecov +74 -0
  8. data/.travis.yml +22 -0
  9. data/.yardopts +4 -0
  10. data/AUTHORS +12 -0
  11. data/CONTRIBUTING.md +47 -0
  12. data/CONTRIBUTORS +76 -0
  13. data/DEV.md +76 -0
  14. data/Gemfile +74 -0
  15. data/Guardfile +30 -0
  16. data/HISTORY.md +705 -0
  17. data/MIT-LICENSE +22 -0
  18. data/README.md +299 -0
  19. data/Rakefile +27 -0
  20. data/TODO.md +118 -0
  21. data/appveyor.yml +31 -0
  22. data/bin/metric_fu +9 -0
  23. data/bin/mf-cane +10 -0
  24. data/bin/mf-churn +10 -0
  25. data/bin/mf-flay +10 -0
  26. data/bin/mf-reek +10 -0
  27. data/bin/mf-roodi +10 -0
  28. data/bin/mf-saikuro +10 -0
  29. data/certs/bf4.pem +22 -0
  30. data/checksum/.gitkeep +0 -0
  31. data/checksum/metric_fu-4.10.0.gem.sha512 +1 -0
  32. data/checksum/metric_fu-4.11.0.gem.sha512 +1 -0
  33. data/checksum/metric_fu-4.11.1.gem.sha512 +1 -0
  34. data/checksum/metric_fu-4.11.2.gem.sha512 +1 -0
  35. data/checksum/metric_fu-4.11.3.gem.sha512 +1 -0
  36. data/checksum/metric_fu-4.11.4.gem.sha512 +1 -0
  37. data/checksum/metric_fu-4.12.0.gem.sha512 +1 -0
  38. data/checksum/metric_fu-4.2.0.gem.sha512 +1 -0
  39. data/checksum/metric_fu-4.2.1.gem.sha512 +1 -0
  40. data/checksum/metric_fu-4.3.0.gem.sha512 +1 -0
  41. data/checksum/metric_fu-4.3.1.gem.sha512 +1 -0
  42. data/checksum/metric_fu-4.4.0.gem.sha512 +1 -0
  43. data/checksum/metric_fu-4.4.1.gem.sha512 +1 -0
  44. data/checksum/metric_fu-4.4.2.gem.sha512 +1 -0
  45. data/checksum/metric_fu-4.4.3.gem.sha512 +1 -0
  46. data/checksum/metric_fu-4.4.4.gem.sha512 +1 -0
  47. data/checksum/metric_fu-4.5.0.gem.sha512 +1 -0
  48. data/checksum/metric_fu-4.5.1.gem.sha512 +1 -0
  49. data/checksum/metric_fu-4.5.2.gem.sha512 +1 -0
  50. data/checksum/metric_fu-4.6.0.gem.sha512 +1 -0
  51. data/checksum/metric_fu-4.7.0.gem.sha512 +1 -0
  52. data/checksum/metric_fu-4.7.1.gem.sha512 +1 -0
  53. data/checksum/metric_fu-4.7.2.gem.sha512 +1 -0
  54. data/checksum/metric_fu-4.7.3.gem.sha512 +1 -0
  55. data/checksum/metric_fu-4.7.4.gem.sha512 +1 -0
  56. data/checksum/metric_fu-4.8.0.gem.sha512 +1 -0
  57. data/checksum/metric_fu-4.9.0.gem.sha512 +1 -0
  58. data/config/roodi_config.yml +22 -0
  59. data/config/rubocop.yml +269 -0
  60. data/gem_tasks/build.rake +197 -0
  61. data/gem_tasks/rubocop.rake +10 -0
  62. data/gem_tasks/usage_test.rake +19 -0
  63. data/gem_tasks/yard.rake +24 -0
  64. data/lib/metric_fu/calculate.rb +10 -0
  65. data/lib/metric_fu/cli/client.rb +26 -0
  66. data/lib/metric_fu/cli/helper.rb +80 -0
  67. data/lib/metric_fu/cli/parser.rb +138 -0
  68. data/lib/metric_fu/configuration.rb +150 -0
  69. data/lib/metric_fu/constantize.rb +57 -0
  70. data/lib/metric_fu/data_structures/line_numbers.rb +112 -0
  71. data/lib/metric_fu/data_structures/location.rb +110 -0
  72. data/lib/metric_fu/data_structures/sexp_node.rb +107 -0
  73. data/lib/metric_fu/environment.rb +129 -0
  74. data/lib/metric_fu/errors/analysis_error.rb +4 -0
  75. data/lib/metric_fu/formatter/html.rb +96 -0
  76. data/lib/metric_fu/formatter/syntax.rb +45 -0
  77. data/lib/metric_fu/formatter/yaml.rb +18 -0
  78. data/lib/metric_fu/formatter.rb +40 -0
  79. data/lib/metric_fu/gem_run.rb +70 -0
  80. data/lib/metric_fu/gem_version.rb +92 -0
  81. data/lib/metric_fu/generator.rb +135 -0
  82. data/lib/metric_fu/io.rb +132 -0
  83. data/lib/metric_fu/loader.rb +105 -0
  84. data/lib/metric_fu/logger.rb +62 -0
  85. data/lib/metric_fu/logging/mf_debugger.rb +23 -0
  86. data/lib/metric_fu/metric.rb +143 -0
  87. data/lib/metric_fu/metrics/cane/generator.rb +95 -0
  88. data/lib/metric_fu/metrics/cane/grapher.rb +37 -0
  89. data/lib/metric_fu/metrics/cane/metric.rb +34 -0
  90. data/lib/metric_fu/metrics/cane/report.html.erb +87 -0
  91. data/lib/metric_fu/metrics/cane/violations.rb +46 -0
  92. data/lib/metric_fu/metrics/churn/generator.rb +37 -0
  93. data/lib/metric_fu/metrics/churn/hotspot.rb +43 -0
  94. data/lib/metric_fu/metrics/churn/metric.rb +29 -0
  95. data/lib/metric_fu/metrics/churn/report.html.erb +58 -0
  96. data/lib/metric_fu/metrics/flay/generator.rb +51 -0
  97. data/lib/metric_fu/metrics/flay/grapher.rb +37 -0
  98. data/lib/metric_fu/metrics/flay/hotspot.rb +52 -0
  99. data/lib/metric_fu/metrics/flay/metric.rb +28 -0
  100. data/lib/metric_fu/metrics/flay/report.html.erb +29 -0
  101. data/lib/metric_fu/metrics/flog/generator.rb +113 -0
  102. data/lib/metric_fu/metrics/flog/grapher.rb +77 -0
  103. data/lib/metric_fu/metrics/flog/hotspot.rb +46 -0
  104. data/lib/metric_fu/metrics/flog/metric.rb +29 -0
  105. data/lib/metric_fu/metrics/flog/report.html.erb +50 -0
  106. data/lib/metric_fu/metrics/hotspots/analysis/analyzed_problems.rb +34 -0
  107. data/lib/metric_fu/metrics/hotspots/analysis/analyzer_tables.rb +114 -0
  108. data/lib/metric_fu/metrics/hotspots/analysis/grouping.rb +23 -0
  109. data/lib/metric_fu/metrics/hotspots/analysis/groupings.rb +12 -0
  110. data/lib/metric_fu/metrics/hotspots/analysis/problems.rb +20 -0
  111. data/lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb +70 -0
  112. data/lib/metric_fu/metrics/hotspots/analysis/ranking.rb +29 -0
  113. data/lib/metric_fu/metrics/hotspots/analysis/rankings.rb +91 -0
  114. data/lib/metric_fu/metrics/hotspots/analysis/record.rb +32 -0
  115. data/lib/metric_fu/metrics/hotspots/analysis/scoring_strategies.rb +24 -0
  116. data/lib/metric_fu/metrics/hotspots/analysis/table.rb +67 -0
  117. data/lib/metric_fu/metrics/hotspots/generator.rb +40 -0
  118. data/lib/metric_fu/metrics/hotspots/hotspot.rb +87 -0
  119. data/lib/metric_fu/metrics/hotspots/hotspot_analyzer.rb +61 -0
  120. data/lib/metric_fu/metrics/hotspots/metric.rb +20 -0
  121. data/lib/metric_fu/metrics/hotspots/report.html.erb +60 -0
  122. data/lib/metric_fu/metrics/rails_best_practices/generator.rb +47 -0
  123. data/lib/metric_fu/metrics/rails_best_practices/grapher.rb +38 -0
  124. data/lib/metric_fu/metrics/rails_best_practices/metric.rb +31 -0
  125. data/lib/metric_fu/metrics/rails_best_practices/report.html.erb +22 -0
  126. data/lib/metric_fu/metrics/rcov/external_client.rb +22 -0
  127. data/lib/metric_fu/metrics/rcov/generator.rb +75 -0
  128. data/lib/metric_fu/metrics/rcov/grapher.rb +37 -0
  129. data/lib/metric_fu/metrics/rcov/hotspot.rb +46 -0
  130. data/lib/metric_fu/metrics/rcov/metric.rb +61 -0
  131. data/lib/metric_fu/metrics/rcov/rcov_format_coverage.rb +149 -0
  132. data/lib/metric_fu/metrics/rcov/rcov_line.rb +48 -0
  133. data/lib/metric_fu/metrics/rcov/report.html.erb +40 -0
  134. data/lib/metric_fu/metrics/rcov/simplecov_formatter.rb +74 -0
  135. data/lib/metric_fu/metrics/reek/generator.rb +97 -0
  136. data/lib/metric_fu/metrics/reek/grapher.rb +55 -0
  137. data/lib/metric_fu/metrics/reek/hotspot.rb +95 -0
  138. data/lib/metric_fu/metrics/reek/metric.rb +26 -0
  139. data/lib/metric_fu/metrics/reek/report.html.erb +35 -0
  140. data/lib/metric_fu/metrics/roodi/generator.rb +41 -0
  141. data/lib/metric_fu/metrics/roodi/grapher.rb +37 -0
  142. data/lib/metric_fu/metrics/roodi/hotspot.rb +39 -0
  143. data/lib/metric_fu/metrics/roodi/metric.rb +24 -0
  144. data/lib/metric_fu/metrics/roodi/report.html.erb +22 -0
  145. data/lib/metric_fu/metrics/saikuro/generator.rb +145 -0
  146. data/lib/metric_fu/metrics/saikuro/hotspot.rb +51 -0
  147. data/lib/metric_fu/metrics/saikuro/metric.rb +31 -0
  148. data/lib/metric_fu/metrics/saikuro/parsing_element.rb +37 -0
  149. data/lib/metric_fu/metrics/saikuro/report.html.erb +71 -0
  150. data/lib/metric_fu/metrics/saikuro/scratch_file.rb +108 -0
  151. data/lib/metric_fu/metrics/stats/generator.rb +82 -0
  152. data/lib/metric_fu/metrics/stats/grapher.rb +40 -0
  153. data/lib/metric_fu/metrics/stats/hotspot.rb +35 -0
  154. data/lib/metric_fu/metrics/stats/metric.rb +28 -0
  155. data/lib/metric_fu/metrics/stats/report.html.erb +44 -0
  156. data/lib/metric_fu/reporter.rb +37 -0
  157. data/lib/metric_fu/reporting/graphs/graph.rb +69 -0
  158. data/lib/metric_fu/reporting/graphs/grapher.rb +66 -0
  159. data/lib/metric_fu/reporting/result.rb +59 -0
  160. data/lib/metric_fu/run.rb +82 -0
  161. data/lib/metric_fu/tasks/metric_fu.rake +54 -0
  162. data/lib/metric_fu/templates/_gem_info.html.erb +8 -0
  163. data/lib/metric_fu/templates/_graph.html.erb +2 -0
  164. data/lib/metric_fu/templates/_report_footer.html.erb +1 -0
  165. data/lib/metric_fu/templates/configuration.rb +25 -0
  166. data/lib/metric_fu/templates/css/bluff.css +15 -0
  167. data/lib/metric_fu/templates/css/buttons.css +82 -0
  168. data/lib/metric_fu/templates/css/default.css +43 -0
  169. data/lib/metric_fu/templates/css/integrity.css +337 -0
  170. data/lib/metric_fu/templates/css/rcov.css +32 -0
  171. data/lib/metric_fu/templates/css/reset.css +7 -0
  172. data/lib/metric_fu/templates/css/syntax.css +19 -0
  173. data/lib/metric_fu/templates/index.html.erb +13 -0
  174. data/lib/metric_fu/templates/javascripts/bluff-min.js +1 -0
  175. data/lib/metric_fu/templates/javascripts/bluff_graph.js +15 -0
  176. data/lib/metric_fu/templates/javascripts/excanvas.js +35 -0
  177. data/lib/metric_fu/templates/javascripts/highcharts.js +294 -0
  178. data/lib/metric_fu/templates/javascripts/highcharts_graph.js +38 -0
  179. data/lib/metric_fu/templates/javascripts/js-class.js +1 -0
  180. data/lib/metric_fu/templates/javascripts/standalone-framework.js +17 -0
  181. data/lib/metric_fu/templates/javascripts/utils.js +9 -0
  182. data/lib/metric_fu/templates/layout.html.erb +41 -0
  183. data/lib/metric_fu/templates/metrics_template.rb +86 -0
  184. data/lib/metric_fu/templates/report.html.erb +31 -0
  185. data/lib/metric_fu/templates/report.rb +41 -0
  186. data/lib/metric_fu/templates/template.rb +247 -0
  187. data/lib/metric_fu/utility.rb +79 -0
  188. data/lib/metric_fu/version.rb +9 -0
  189. data/lib/metric_fu.rb +143 -0
  190. data/metric_fu.gemspec +72 -0
  191. data/spec/capture_warnings.rb +55 -0
  192. data/spec/cli/helper_spec.rb +165 -0
  193. data/spec/dummy/.gitignore +1 -0
  194. data/spec/dummy/.gitkeep +0 -0
  195. data/spec/dummy/.metrics +4 -0
  196. data/spec/dummy/lib/.gitkeep +0 -0
  197. data/spec/dummy/lib/bad_encoding.rb +6 -0
  198. data/spec/dummy/spec/.gitkeep +0 -0
  199. data/spec/fixtures/20090630.yml +7922 -0
  200. data/spec/fixtures/coverage-153.rb +11 -0
  201. data/spec/fixtures/coverage.rb +13 -0
  202. data/spec/fixtures/exit0.sh +3 -0
  203. data/spec/fixtures/exit1.sh +3 -0
  204. data/spec/fixtures/hotspots/flog.yml +86 -0
  205. data/spec/fixtures/hotspots/generator.yml +47 -0
  206. data/spec/fixtures/hotspots/generator_analysis.yml +53 -0
  207. data/spec/fixtures/hotspots/reek.yml +14 -0
  208. data/spec/fixtures/hotspots/roodi.yml +13 -0
  209. data/spec/fixtures/hotspots/saikuro.yml +27 -0
  210. data/spec/fixtures/hotspots/several_metrics.yml +47 -0
  211. data/spec/fixtures/hotspots/stats.yml +4 -0
  212. data/spec/fixtures/hotspots/three_metrics_on_same_file.yml +36 -0
  213. data/spec/fixtures/line_numbers/foo.rb +33 -0
  214. data/spec/fixtures/line_numbers/module.rb +11 -0
  215. data/spec/fixtures/line_numbers/module_surrounds_class.rb +15 -0
  216. data/spec/fixtures/line_numbers/two_classes.rb +11 -0
  217. data/spec/fixtures/metric_missing.yml +1 -0
  218. data/spec/fixtures/rcov_output.txt +135 -0
  219. data/spec/fixtures/saikuro/app/controllers/sessions_controller.rb_cyclo.html +10 -0
  220. data/spec/fixtures/saikuro/app/controllers/users_controller.rb_cyclo.html +16 -0
  221. data/spec/fixtures/saikuro/index_cyclo.html +155 -0
  222. data/spec/fixtures/saikuro_sfiles/thing.rb_cyclo.html +11 -0
  223. data/spec/metric_fu/calculate_spec.rb +21 -0
  224. data/spec/metric_fu/configuration_spec.rb +90 -0
  225. data/spec/metric_fu/data_structures/line_numbers_spec.rb +63 -0
  226. data/spec/metric_fu/data_structures/location_spec.rb +110 -0
  227. data/spec/metric_fu/formatter/configuration_spec.rb +44 -0
  228. data/spec/metric_fu/formatter/html_spec.rb +138 -0
  229. data/spec/metric_fu/formatter/yaml_spec.rb +61 -0
  230. data/spec/metric_fu/formatter_spec.rb +49 -0
  231. data/spec/metric_fu/gem_version_spec.rb +12 -0
  232. data/spec/metric_fu/generator_spec.rb +130 -0
  233. data/spec/metric_fu/loader_spec.rb +10 -0
  234. data/spec/metric_fu/metric_spec.rb +46 -0
  235. data/spec/metric_fu/metrics/cane/configuration_spec.rb +22 -0
  236. data/spec/metric_fu/metrics/cane/generator_spec.rb +184 -0
  237. data/spec/metric_fu/metrics/churn/configuration_spec.rb +13 -0
  238. data/spec/metric_fu/metrics/churn/generator_spec.rb +64 -0
  239. data/spec/metric_fu/metrics/flay/configuration_spec.rb +13 -0
  240. data/spec/metric_fu/metrics/flay/generator_spec.rb +105 -0
  241. data/spec/metric_fu/metrics/flay/grapher_spec.rb +57 -0
  242. data/spec/metric_fu/metrics/flog/configuration_spec.rb +18 -0
  243. data/spec/metric_fu/metrics/flog/generator_spec.rb +77 -0
  244. data/spec/metric_fu/metrics/flog/grapher_spec.rb +107 -0
  245. data/spec/metric_fu/metrics/hotspots/analysis/analyzed_problems_spec.rb +104 -0
  246. data/spec/metric_fu/metrics/hotspots/analysis/analyzer_tables_spec.rb +71 -0
  247. data/spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb +30 -0
  248. data/spec/metric_fu/metrics/hotspots/analysis/rankings_spec.rb +97 -0
  249. data/spec/metric_fu/metrics/hotspots/analysis/table_spec.rb +6 -0
  250. data/spec/metric_fu/metrics/hotspots/generator_spec.rb +46 -0
  251. data/spec/metric_fu/metrics/hotspots/hotspot_analyzer_spec.rb +10 -0
  252. data/spec/metric_fu/metrics/hotspots/hotspot_spec.rb +16 -0
  253. data/spec/metric_fu/metrics/rails_best_practices/configuration_spec.rb +55 -0
  254. data/spec/metric_fu/metrics/rails_best_practices/generator_spec.rb +33 -0
  255. data/spec/metric_fu/metrics/rails_best_practices/grapher_spec.rb +62 -0
  256. data/spec/metric_fu/metrics/rcov/configuration_spec.rb +28 -0
  257. data/spec/metric_fu/metrics/rcov/generator_spec.rb +22 -0
  258. data/spec/metric_fu/metrics/rcov/grapher_spec.rb +57 -0
  259. data/spec/metric_fu/metrics/rcov/hotspot_spec.rb +20 -0
  260. data/spec/metric_fu/metrics/rcov/rcov_line_spec.rb +89 -0
  261. data/spec/metric_fu/metrics/rcov/simplecov_formatter_spec.rb +67 -0
  262. data/spec/metric_fu/metrics/reek/configuration_spec.rb +13 -0
  263. data/spec/metric_fu/metrics/reek/generator_spec.rb +169 -0
  264. data/spec/metric_fu/metrics/reek/grapher_spec.rb +66 -0
  265. data/spec/metric_fu/metrics/roodi/configuration_spec.rb +14 -0
  266. data/spec/metric_fu/metrics/roodi/generator_spec.rb +82 -0
  267. data/spec/metric_fu/metrics/roodi/grapher_spec.rb +57 -0
  268. data/spec/metric_fu/metrics/saikuro/configuration_spec.rb +25 -0
  269. data/spec/metric_fu/metrics/saikuro/generator_spec.rb +71 -0
  270. data/spec/metric_fu/metrics/stats/generator_spec.rb +96 -0
  271. data/spec/metric_fu/metrics/stats/grapher_spec.rb +69 -0
  272. data/spec/metric_fu/reporter_spec.rb +41 -0
  273. data/spec/metric_fu/reporting/graphs/graph_spec.rb +44 -0
  274. data/spec/metric_fu/reporting/graphs/grapher_spec.rb +24 -0
  275. data/spec/metric_fu/reporting/result_spec.rb +50 -0
  276. data/spec/metric_fu/run_spec.rb +197 -0
  277. data/spec/metric_fu/templates/configuration_spec.rb +51 -0
  278. data/spec/metric_fu/templates/metrics_template_spec.rb +11 -0
  279. data/spec/metric_fu/templates/report_spec.rb +15 -0
  280. data/spec/metric_fu/templates/template_spec.rb +233 -0
  281. data/spec/metric_fu/utility_spec.rb +12 -0
  282. data/spec/metric_fu_spec.rb +33 -0
  283. data/spec/quality_spec.rb +114 -0
  284. data/spec/shared/configured.rb +45 -0
  285. data/spec/shared/test_coverage.rb +95 -0
  286. data/spec/spec_helper.rb +54 -0
  287. data/spec/support/deferred_garbaged_collection.rb +33 -0
  288. data/spec/support/helper_methods.rb +32 -0
  289. data/spec/support/matcher_create_file.rb +37 -0
  290. data/spec/support/matcher_create_files.rb +43 -0
  291. data/spec/support/suite.rb +26 -0
  292. data/spec/support/test_fixtures.rb +37 -0
  293. data/spec/support/timeout.rb +7 -0
  294. data/spec/support/usage_test.rb +150 -0
  295. data/spec/usage_test_spec.rb +93 -0
  296. metadata +757 -0
@@ -0,0 +1 @@
1
+ a1ff91abb134992e958518efddea3faaee87d987d4f7d6190a065eff5647514b9e58d16c78db061f42a53429f1647f47f3efda1bc75f746a342b9ba50bf72b1c
@@ -0,0 +1 @@
1
+ cecb4dabfef6d7f955f394a9af5a8755cae4269196dfe6f4447f0d465426a8c4bb777572d3dc8404de352c0e64dd74562b6b8e65687ca79bdd247d3fbafe6e69
@@ -0,0 +1 @@
1
+ b9488463cdbac040cc3f4fdff3ec18385b3129876464ae14de2078c1742a1be7951ba40b7f2efba54809cb8e7766fc53ff63c2672ffd25452ddca2f9a9387ac4
@@ -0,0 +1 @@
1
+ 7abc57b0cf4a342710a2dc53f9113c4797b0260912e68f386888692a72b84631bf81cee47aa9deba81ea3ddb07f8302b08279562c0802a678d78b7cc3c32ad38
@@ -0,0 +1 @@
1
+ c7769b05094f900a0b48c1e8b9e4df67372223e0540d97c94109eb00af5acf32cb20615c8c5adcf7352a3ee1ad1b3106b5b20b87ebccc3dfc86a21ca5709490b
@@ -0,0 +1 @@
1
+ ad47170c438b84335051bae41480a00dec428e1f755a70813364c6232f43d16c15c55813ffb555e5236189360fe84bfcbe194e6cd54b304d3b2688985b3609ac
@@ -0,0 +1 @@
1
+ 9a3c76074181ca4ec770f1a52f652268e44af10648cf82cb641672d2075d92133751ad275ad1ba417c473ba8095d872df762eb379e2e48fd38ce1db06b4ea1e7
@@ -0,0 +1 @@
1
+ 26caa046f537a1a81415bf5f238a7cd36a5b1c1f3f2e1008276e0fdbb35d08925fbf3f2bdd95477f75f716088639630cebec9ca5d300f03d6cd6cb3ae1c437dc
@@ -0,0 +1 @@
1
+ d46528ba18e30ce561e3d0dfb4245ee2e4b7ff72a895cff24cb4bb4a86ace4ed3f759eba96b26aa9e512ebd253d78d9697423bf468c09a09fb764597977f26c2
@@ -0,0 +1 @@
1
+ 6a59eb643743ccb2d34c7de915a0c448c6409a8b31a76b5bc8315fced802e5e186f8d97a7973c95ba306ac17d7de59d015cd93c50bda56180a952c91ac56c216
@@ -0,0 +1,22 @@
1
+ ---
2
+ CaseMissingElseCheck: {}
3
+ ClassLineCountCheck:
4
+ line_count: 300
5
+ ClassNameCheck:
6
+ pattern: !ruby/regexp /^[A-Z][a-zA-Z0-9]*$/
7
+ CyclomaticComplexityBlockCheck:
8
+ complexity: 4
9
+ CyclomaticComplexityMethodCheck:
10
+ complexity: 8
11
+ EmptyRescueBodyCheck: {}
12
+ ForLoopCheck: {}
13
+ MethodLineCountCheck:
14
+ line_count: 20
15
+ MethodNameCheck:
16
+ pattern: !ruby/regexp /^[_a-z<>=\[\]|+-\/\*`]+[_a-z0-9_<>=~@\[\]]*[=!\?]?$/
17
+ ModuleLineCountCheck:
18
+ line_count: 300
19
+ ModuleNameCheck:
20
+ pattern: !ruby/regexp /^[A-Z][a-zA-Z0-9]*$/
21
+ ParameterNumberCheck:
22
+ parameter_count: 5
@@ -0,0 +1,269 @@
1
+ # Originally from https://github.com/thoughtbot/hound/blob/master/config/style_guides/ruby.yml
2
+ # also see
3
+ # https://github.com/bbatsov/rubocop/blob/master/config/enabled.yml
4
+ # https://github.com/rom-rb/devtools/blob/master/config/rubocop.yml
5
+ # https://github.com/rom-rb/devtools/blob/master/default/config/rubocop.yml
6
+ AllCops:
7
+ Exclude:
8
+ - db/schema.rb
9
+
10
+ Style/Blocks:
11
+ Description: 'Allow Jim Weirch-style blocks, i.e. use `{}` for blocks whose return value we use, else `do/end`'
12
+ StyleGuide: 'http://devblog.avdi.org/2011/07/26/the-procedurefunction-block-convention-in-ruby/'
13
+ Enabled: false
14
+
15
+ AccessorMethodName:
16
+ Enabled: false
17
+
18
+ ActionFilter:
19
+ Enabled: false
20
+
21
+ Alias:
22
+ Enabled: false
23
+
24
+ ArrayJoin:
25
+ Enabled: false
26
+
27
+ AsciiComments:
28
+ Enabled: false
29
+
30
+ AsciiIdentifiers:
31
+ Enabled: false
32
+
33
+ Attr:
34
+ Enabled: false
35
+
36
+ BlockNesting:
37
+ Enabled: false
38
+
39
+ CaseEquality:
40
+ Enabled: false
41
+
42
+ CharacterLiteral:
43
+ Enabled: false
44
+
45
+ ClassAndModuleChildren:
46
+ Enabled: false
47
+
48
+ ClassLength:
49
+ Enabled: false
50
+
51
+ ClassVars:
52
+ Enabled: false
53
+
54
+ CollectionMethods:
55
+ PreferredMethods:
56
+ find: detect
57
+ reduce: inject
58
+ collect: map
59
+ find_all: select
60
+
61
+ ColonMethodCall:
62
+ Enabled: false
63
+
64
+ CommentAnnotation:
65
+ Enabled: false
66
+
67
+ CyclomaticComplexity:
68
+ Enabled: false
69
+
70
+ Delegate:
71
+ Enabled: false
72
+
73
+ DeprecatedHashMethods:
74
+ Enabled: false
75
+
76
+ Documentation:
77
+ Enabled: false
78
+
79
+ DotPosition:
80
+ EnforcedStyle: trailing
81
+
82
+ DoubleNegation:
83
+ Enabled: false
84
+
85
+ EachWithObject:
86
+ Enabled: false
87
+
88
+ EmptyLiteral:
89
+ Enabled: false
90
+
91
+ Encoding:
92
+ Enabled: false
93
+
94
+ EvenOdd:
95
+ Enabled: false
96
+
97
+ FileName:
98
+ Enabled: false
99
+
100
+ FlipFlop:
101
+ Enabled: false
102
+
103
+ FormatString:
104
+ Enabled: false
105
+
106
+ GlobalVars:
107
+ Enabled: false
108
+
109
+ GuardClause:
110
+ Enabled: false
111
+
112
+ IfUnlessModifier:
113
+ Enabled: false
114
+
115
+ IfWithSemicolon:
116
+ Enabled: false
117
+
118
+ InlineComment:
119
+ Enabled: false
120
+
121
+ Lambda:
122
+ Enabled: false
123
+
124
+ LambdaCall:
125
+ Enabled: false
126
+
127
+ LineEndConcatenation:
128
+ Enabled: false
129
+
130
+ LineLength:
131
+ Max: 80
132
+
133
+ MethodLength:
134
+ Enabled: false
135
+
136
+ ModuleFunction:
137
+ Enabled: false
138
+
139
+ NegatedIf:
140
+ Enabled: false
141
+
142
+ NegatedWhile:
143
+ Enabled: false
144
+
145
+ Next:
146
+ Enabled: false
147
+
148
+ NilComparison:
149
+ Enabled: false
150
+
151
+ Not:
152
+ Enabled: false
153
+
154
+ NumericLiterals:
155
+ Enabled: false
156
+
157
+ OneLineConditional:
158
+ Enabled: false
159
+
160
+ OpMethod:
161
+ Enabled: false
162
+
163
+ ParameterLists:
164
+ Enabled: false
165
+
166
+ PercentLiteralDelimiters:
167
+ Enabled: false
168
+
169
+ PerlBackrefs:
170
+ Enabled: false
171
+
172
+ PredicateName:
173
+ NamePrefixBlacklist:
174
+ - is_
175
+
176
+ Proc:
177
+ Enabled: false
178
+
179
+ RaiseArgs:
180
+ Enabled: false
181
+
182
+ RegexpLiteral:
183
+ Enabled: false
184
+
185
+ SelfAssignment:
186
+ Enabled: false
187
+
188
+ SingleLineBlockParams:
189
+ Enabled: false
190
+
191
+ SingleLineMethods:
192
+ Enabled: false
193
+
194
+ SignalException:
195
+ Enabled: false
196
+
197
+ SpecialGlobalVars:
198
+ Enabled: false
199
+
200
+ StringLiterals:
201
+ EnforcedStyle: double_quotes
202
+
203
+ VariableInterpolation:
204
+ Enabled: false
205
+
206
+ TrailingComma:
207
+ Enabled: false
208
+
209
+ TrivialAccessors:
210
+ Enabled: false
211
+
212
+ VariableInterpolation:
213
+ Enabled: false
214
+
215
+ WhenThen:
216
+ Enabled: false
217
+
218
+ WhileUntilModifier:
219
+ Enabled: false
220
+
221
+ WordArray:
222
+ Enabled: false
223
+
224
+ # Lint
225
+
226
+ AmbiguousOperator:
227
+ Enabled: false
228
+
229
+ AmbiguousRegexpLiteral:
230
+ Enabled: false
231
+
232
+ AssignmentInCondition:
233
+ Enabled: false
234
+
235
+ ConditionPosition:
236
+ Enabled: false
237
+
238
+ DeprecatedClassMethods:
239
+ Enabled: false
240
+
241
+ ElseLayout:
242
+ Enabled: false
243
+
244
+ HandleExceptions:
245
+ Enabled: false
246
+
247
+ InvalidCharacterLiteral:
248
+ Enabled: false
249
+
250
+ LiteralInCondition:
251
+ Enabled: false
252
+
253
+ LiteralInInterpolation:
254
+ Enabled: false
255
+
256
+ Loop:
257
+ Enabled: false
258
+
259
+ ParenthesesAsGroupedExpression:
260
+ Enabled: false
261
+
262
+ RequireParentheses:
263
+ Enabled: false
264
+
265
+ UnderscorePrefixedVariableName:
266
+ Enabled: false
267
+
268
+ Void:
269
+ Enabled: false
@@ -0,0 +1,197 @@
1
+ # encoding: utf-8
2
+ require 'rubygems'
3
+ require 'digest/sha2'
4
+ require 'rake/tasklib'
5
+ # require 'bundler/gem_helper'
6
+ # Bundler::GemHelper.install_tasks
7
+
8
+ # Based on https://github.com/bundler/bundler/blob/ec0621d/lib/bundler/gem_helpers.rb
9
+ GEM_TASKS = Class.new(Rake::TaskLib) do
10
+ include Rake::DSL if defined? Rake::DSL
11
+ attr_reader :base
12
+ def initialize
13
+ @base = File.expand_path('../..', __FILE__)
14
+ @gemspec_path = File.join(base, 'metric_fu.gemspec')
15
+ @gemspec = Gem::Specification.load(@gemspec_path)
16
+ end
17
+
18
+ def install
19
+ built_gem_path = nil
20
+
21
+ desc "Build #{built_gem_name} into the pkg directory."
22
+ task 'build' do
23
+ built_gem_path = build_gem
24
+ end
25
+
26
+ desc "Build and install #{built_gem_name} into system gems."
27
+ task 'install' => 'build' do
28
+ install_gem(built_gem_path)
29
+ end
30
+
31
+ desc 'Creates and commits a SHA512 checksum of the current version built gem'
32
+ task 'checksum' => 'build' do
33
+ add_checksum(built_gem_path)
34
+ end
35
+
36
+ desc "Create tag #{version_tag} and build and push #{built_gem_name} to Rubygems"
37
+ task 'release' => 'checksum' do
38
+ release_gem(built_gem_path)
39
+ end
40
+
41
+ end
42
+
43
+ def build_gem
44
+ file_name = nil
45
+ sh("gem build -V '#{@gemspec_path}'") { |out, code|
46
+ file_name = File.basename(built_gem_path)
47
+ FileUtils.mkdir_p(File.join(base, 'pkg'))
48
+ FileUtils.mv(built_gem_path, 'pkg')
49
+ STDOUT.puts "#{name} #{version} built to pkg/#{file_name}."
50
+ }
51
+ File.join(base, 'pkg', file_name)
52
+ end
53
+
54
+ def install_gem(built_gem_path=nil)
55
+ built_gem_path ||= build_gem
56
+ out, _ = sh_with_code("gem install '#{built_gem_path}' --local")
57
+ raise "Couldn't install gem, run `gem install #{built_gem_path}' for more detailed output" unless out[/Successfully installed/]
58
+ STDOUT.puts "#{name} (#{version}) installed."
59
+ end
60
+ # Based on https://github.com/YorickPeterse/ruby-lint/blob/3e946/task/checksum.rake
61
+ def add_checksum(built_gem_path=nil)
62
+ guard_clean
63
+ built_gem_path ||= build_gem
64
+ checksum_file = File.join(checksums, checksum_name)
65
+ File.open(checksum_file, 'w') do |handle|
66
+ handle.write(gem_checksum(built_gem_path))
67
+ end
68
+ sh_with_code("git add #{checksum_file} && git commit -m 'Add checksum for #{built_gem_name}'")
69
+ end
70
+
71
+ def checksums
72
+ File.expand_path('../../checksum', __FILE__)
73
+ end
74
+
75
+ def checksum_name
76
+ File.basename(built_gem_name) + '.sha512'
77
+ end
78
+
79
+ def gem_checksum(built_gem_path)
80
+ checksum(File.read(built_gem_path))
81
+ end
82
+
83
+ def checksum(content)
84
+ Digest::SHA512.new.hexdigest(content)
85
+ end
86
+
87
+ def release_gem(built_gem_path=nil)
88
+ guard_clean
89
+ built_gem_path ||= build_gem
90
+ add_checksum(built_gem_path) #unless already hashed?
91
+ tag_version { git_push } unless already_tagged?
92
+ rubygem_push(built_gem_path) if gem_push?
93
+ end
94
+
95
+ protected
96
+
97
+ def rubygem_push(path)
98
+ if Pathname.new("~/.gem/credentials").expand_path.exist?
99
+ sh("gem push '#{path}'")
100
+ STDOUT.puts "Pushed #{name} #{version} to rubygems.org."
101
+ else
102
+ raise "Your rubygems.org credentials aren't set. Run `gem push` to set them."
103
+ end
104
+ end
105
+
106
+ def built_gem_path
107
+ Dir[File.join(base, "#{name}-*.gem")].sort_by{|f| File.mtime(f)}.last
108
+ end
109
+
110
+ def git_push
111
+ perform_git_push
112
+ perform_git_push ' --tags'
113
+ STDOUT.puts "Pushed git commits and tags."
114
+ end
115
+
116
+ def perform_git_push(options = '')
117
+ cmd = "git push #{options}"
118
+ out, code = sh_with_code(cmd)
119
+ raise "Couldn't git push. `#{cmd}' failed with the following output:\n\n#{out}\n" unless code == 0
120
+ end
121
+
122
+ def already_tagged?
123
+ if sh('git tag').split(/\n/).include?(version_tag)
124
+ STDOUT.puts "Tag #{version_tag} has already been created."
125
+ true
126
+ end
127
+ end
128
+
129
+ def guard_clean
130
+ clean? && committed? or raise("There are files that need to be committed first.")
131
+ end
132
+
133
+ def clean?
134
+ sh_with_code("git diff --exit-code")[1] == 0
135
+ end
136
+
137
+ def committed?
138
+ sh_with_code("git diff-index --quiet --cached HEAD")[1] == 0
139
+ end
140
+
141
+ def tag_version
142
+ sh "git tag -a -m \"Version #{version}\" #{version_tag}"
143
+ STDOUT.puts "Tagged #{version_tag}."
144
+ yield if block_given?
145
+ rescue
146
+ STDERR.puts "Untagging #{version_tag} due to error."
147
+ sh_with_code "git tag -d #{version_tag}"
148
+ raise
149
+ end
150
+
151
+ def version
152
+ @gemspec.version
153
+ end
154
+
155
+ def version_tag
156
+ "v#{version}"
157
+ end
158
+
159
+ def name
160
+ @gemspec.name
161
+ end
162
+
163
+ def built_gem_name
164
+ "#{name}-#{version}.gem"
165
+ end
166
+
167
+ def sh(cmd, &block)
168
+ out, code = sh_with_code(cmd, &block)
169
+ code == 0 ? out : raise(out.empty? ? "Running `#{cmd}' failed. Run this command directly for more detailed output." : out)
170
+ end
171
+
172
+ def sh_with_code(cmd, &block)
173
+ cmd << " 2>&1"
174
+ outbuf = ''
175
+ p cmd
176
+ Dir.chdir(base) {
177
+ outbuf = `#{cmd}`
178
+ if $? == 0
179
+ block.call(outbuf) if block
180
+ end
181
+ }
182
+ [outbuf, $?]
183
+ end
184
+
185
+ def gem_push?
186
+ ! %w{n no nil false off 0}.include?(ENV['gem_push'].to_s.downcase)
187
+ end
188
+
189
+ end.new.install
190
+
191
+ # Based on https://github.com/YorickPeterse/ruby-lint/blob/3e946e6/task/todo.rake
192
+ desc 'Extracts TODO tags and the likes'
193
+ task :todo do
194
+ regex = %w{NOTE: FIXME: TODO: THINK: @todo}.join('|')
195
+
196
+ sh "ack '#{regex}' lib"
197
+ end
@@ -0,0 +1,10 @@
1
+ if ENV["FULL_BUILD"] != "true" # skip on Travis
2
+ require "rubocop/rake_task"
3
+ RuboCop::RakeTask.new(:rubocop) do |task|
4
+ task.patterns = ["lib", "spec"]
5
+ task.formatters = ["progress"]
6
+ task.options = ["--display-cop-names"]
7
+ task.fail_on_error = false
8
+ task.verbose = false
9
+ end
10
+ end
@@ -0,0 +1,19 @@
1
+ ROOT_PATH = File.expand_path("..", File.dirname(__FILE__))
2
+ require File.join(ROOT_PATH, 'spec', 'support', 'usage_test')
3
+ LIB_PATH = File.join(ROOT_PATH, 'lib')
4
+ BIN_PATH = File.join(ROOT_PATH, 'bin')
5
+ EXAMPLE_FILES = [
6
+ File.join(ROOT_PATH, 'README.md'),
7
+ File.join(ROOT_PATH, 'DEV.md')
8
+ ]
9
+ task "load_path" do
10
+ $LOAD_PATH.unshift(LIB_PATH)
11
+ $VERBOSE = nil
12
+ ENV['PATH'] = "#{BIN_PATH}:#{ENV['PATH']}"
13
+ ENV['CC_BUILD_ARTIFACTS'] = 'turn_off_browser_opening'
14
+ end
15
+ desc "Test that documentation usage works"
16
+ task "usage_test" => %w[load_path] do
17
+ usage_test = UsageTest.new
18
+ usage_test.test_files(EXAMPLE_FILES)
19
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+
3
+ begin
4
+ require "yard"
5
+ rescue LoadError
6
+ else
7
+ namespace :yard do
8
+ YARD::Rake::YardocTask.new(:doc) do |t|
9
+ t.stats_options = ["--list-undoc"]
10
+ end
11
+
12
+ desc "start a gem server"
13
+ task :server do
14
+ sh "bundle exec yard server --gems"
15
+ end
16
+
17
+ desc "use Graphviz to generate dot graph"
18
+ task :graph do
19
+ output_file = "doc/erd.dot"
20
+ sh "bundle exec yard graph --protected --full --dependencies > #{output_file}"
21
+ puts "open doc/erd.dot if you have graphviz installed"
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,10 @@
1
+ module MetricFu
2
+ module Calculate
3
+ module_function
4
+
5
+ def integer_percent(num, total)
6
+ return 0 if total.zero?
7
+ (Float(num) / Float(total) * 100).round
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,26 @@
1
+ require "metric_fu"
2
+ require "metric_fu/cli/helper"
3
+ require "metric_fu/cli/parser"
4
+ module MetricFu
5
+ module Cli
6
+ class Client
7
+ def initialize
8
+ @helper = MetricFu::Cli::Helper.new
9
+ end
10
+
11
+ def shutdown
12
+ @helper.shutdown
13
+ end
14
+
15
+ def run(argv = ARGV.dup)
16
+ options = @helper.process_options(argv)
17
+ mf_debug "Got options #{options.inspect}"
18
+ if options[:run]
19
+ @helper.run(options)
20
+ else
21
+ STDOUT.puts @helper.usage
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,80 @@
1
+ require "metric_fu"
2
+ require "metric_fu/cli/parser"
3
+ MetricFu.lib_require { "run" }
4
+ # see https://github.com/grosser/pru/blob/master/bin/pru
5
+ module MetricFu
6
+ module Cli
7
+ def self.immediate_shutdown!
8
+ exit(1)
9
+ end
10
+ def self.complete!
11
+ exit(0)
12
+ end
13
+ class Helper
14
+ def initialize
15
+ @metric_fu = MetricFu::Run.new
16
+ end
17
+
18
+ def run(options = {})
19
+ @metric_fu.run(options)
20
+ complete
21
+ end
22
+
23
+ def version
24
+ MetricFu::VERSION
25
+ end
26
+
27
+ def shutdown
28
+ out "\nShutting down. Bye"
29
+ MetricFu::Cli.immediate_shutdown!
30
+ end
31
+
32
+ def banner
33
+ "MetricFu: A Fistful of code metrics"
34
+ end
35
+
36
+ def usage
37
+ <<-EOS
38
+ #{banner}
39
+ Use --help for help
40
+ EOS
41
+ end
42
+
43
+ def executable_name
44
+ "metric_fu"
45
+ end
46
+
47
+ def metrics
48
+ MetricFu::Metric.metrics.map(&:name).sort_by(&:to_s)
49
+ end
50
+
51
+ def process_options(argv = [])
52
+ options = MetricFu::Cli::MicroOptParse::Parser.new do |p|
53
+ p.banner = banner
54
+ p.version = version
55
+ p.option :run, "Run all metrics with defaults", default: true
56
+ metrics.each do |metric|
57
+ p.option metric.to_sym, "Enables or disables #{metric}", default: true # , :value_in_set => [true, false]
58
+ end
59
+ p.option :open, "Open report in browser (if supported by formatter)", default: true
60
+ end.process!(argv)
61
+ options
62
+ end
63
+
64
+ private
65
+
66
+ def out(text)
67
+ STDOUT.puts text
68
+ end
69
+
70
+ def error(text)
71
+ STDERR.puts text
72
+ end
73
+
74
+ def complete
75
+ out "all done"
76
+ MetricFu::Cli.complete!
77
+ end
78
+ end
79
+ end
80
+ end