cuke_sniffer 0.0.8 → 1.0.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.
@@ -0,0 +1,81 @@
1
+ <div class="row">
2
+ <div class="panel panel-default">
3
+ <div class="panel-heading panel-title" data-toggle="collapse" data-target="#information" >
4
+ Information <span class="glyphicon glyphicon-menu-down"></span>
5
+ </div>
6
+ <div id="information" class="panel-body collapse">
7
+ <div class="col-md-12">
8
+ <div class="col-md-1">
9
+ <h4>Purpose:</h4>
10
+ </div>
11
+ <div class="col-md-11">
12
+ As users of Cucumber we are developers that wish to treat our testing projects with the same respect and
13
+ quality as our production and user facing code. We wish to follow best practices and to avoid falling into
14
+ some of the anti patterns that are easy to slip into using Cucumber. Cuke Sniffer was made to aid in the
15
+ identification of these issues. The list of improvements has been constructed on opinions from the authors
16
+ and feedback from community members. Not everyone will share these opinions and for that reason all
17
+ improvements can be turned off when generating this report. See the
18
+ <a target="_blank" href="https://github.com/r-cochran/cuke_sniffer/wiki">wiki</a> for instructions on how.
19
+ </div>
20
+ </div>
21
+ <div class="col-md-12">
22
+ <div class="col-md-1">
23
+ <h4>Scoring:</h4>
24
+ </div>
25
+ <div class="col-md-11">
26
+ Scoring is based on the number of 'smells' in a cucumber project, where smells are potential misuses or
27
+ errors. Cuke Sniffer follows a 'golf score' type system where the lower the number, the better. 'Min' refers
28
+ to the overall best score for a particular object and the 'Max' is the overall worst object score. The score
29
+ is <u>relative</u> to each project and should be used to compare the project and teams growth.
30
+ </div>
31
+ </div>
32
+ <div class="col-md-12">
33
+ <div class="col-md-1">
34
+ <h4>Authors:</h4>
35
+ </div>
36
+ <div class="col-md-11">
37
+ <div>
38
+ Robert Cochran <a target="_blank" href="https://twitter.com/cochrarj"><i class="fa fa-twitter"></i></a>
39
+ </div>
40
+ <div>
41
+ Robert Anderson <a target="_blank" href="https://twitter.com/bobthesatyr1337"><i class="fa fa-twitter"></i></a>
42
+ </div>
43
+ <div>
44
+ Christopher Vaughn <a target="_blank" href="https://twitter.com/mistercvaughn"><i class="fa fa-twitter"></i></a>
45
+ </div>
46
+ </div>
47
+ </div>
48
+ <div class="col-md-12">
49
+ <div class="col-md-1">
50
+ <h4>Links:</h4>
51
+ </div>
52
+ <div class="col-md-11">
53
+ <div>
54
+ <div>
55
+ <a target="_blank" href="https://github.com/r-cochran/cuke_sniffer/issues">
56
+ <span class="fa fa-bug"></span> Report Issues
57
+ </a>
58
+
59
+ </div>
60
+ <div>
61
+ <a target="_blank" href="https://github.com/r-cochran/cuke_sniffer/wiki/Patch-notes">
62
+ <span class="fa fa-list"></span> Patch Notes
63
+ </a>
64
+
65
+ </div>
66
+ <div>
67
+ <a target="_blank" href="https://github.com/r-cochran/cuke_sniffer/blob/master/LICENSE">
68
+ <span class="fa fa-balance-scale"></span> License
69
+ </a>
70
+ </div>
71
+ <div>
72
+ <a target="_blank" href="https://github.com/r-cochran/cuke_sniffer/wiki">
73
+ <span class="fa fa-newspaper-o"></span> Wiki
74
+ </a>
75
+ </div>
76
+ </div>
77
+ </div>
78
+ </div>
79
+ </div>
80
+ </div>
81
+ </div>
@@ -1,65 +1,9 @@
1
- <script type="text/javascript">
2
-
3
- function collapseAll(css_class) {
4
- updateAll(css_class, "none");
5
- }
6
-
7
- function expandAll(css_class) {
8
- updateAll(css_class, "inline-block");
9
- }
10
-
11
- function expandAllShiftingRows(css_class) {
12
- var elements = document.getElementsByClassName(css_class)
13
- for (var i = 0; i < elements.length; i++) {
14
- existing_style = elements.item(i).getAttribute('style');
15
- elements.item(i).setAttribute('style', existing_style.replace(/display:\s*none/, "display: block-inline"));
16
- }
17
- }
18
-
19
- function updateAll(css_class, display_type){
20
- var elements = document.getElementsByClassName(css_class)
21
- for (var i = 0; i < elements.length; i++) {
22
- elements.item(i).style.display = display_type;
23
- }
24
- }
25
-
26
- function toggleById(item, link) {
27
- updateDisplayStatus(document.getElementById(item));
28
- toggleText(link)
29
- }
30
- function updateDisplayStatus(object) {
31
- if (object.tagName == "TR") {
32
- updateDisplayStatusForTR(object);
33
- } else {
34
- object.style.display = (object.style.display == "block") ? 'none' : "block";
35
- }
36
- }
37
-
38
- function updateDivScroll(divId, tableId) {
39
- div = document.getElementById(divId);
40
- table = document.getElementById(tableId);
41
- if (table.offsetHeight >= 500) {
42
- div.style.height = "75%";
43
- div.style.overflow = "auto";
44
- } else {
45
- div.style.height = "";
46
- div.style.overflow = "none";
47
- }
48
-
49
- }
50
-
51
- function updateDisplayStatusForTR(object) {
52
- existing_style = object.getAttribute('style');
53
- if (object.style.display == "none") {
54
- object.setAttribute('style', existing_style.replace(/display:\s*none/, "display: block-inline"))
55
- } else {
56
- object.setAttribute('style', existing_style.replace("display: block-inline", "display: none"))
57
- }
58
- }
59
- function toggleText(link) {
60
- var char_result = link.innerHTML.indexOf("+") > -1 ? "-" : "+";
61
- link.innerHTML = link.innerHTML.replace(/(\+|\-)/, char_result)
62
- }
63
-
64
-
65
- </script>
1
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
2
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
3
+
4
+ <script type="text/javascript">
5
+ <%= build_page(cuke_sniffer, "../js/cuke_sniffer.js") %>
6
+ $(document).ready(function(){
7
+ CukeSniffer.init();
8
+ });
9
+ </script>
@@ -2,15 +2,20 @@
2
2
  styles = build_page(cuke_sniffer, "css.html.erb")
3
3
  scripts = build_page(cuke_sniffer, "js.html.erb")
4
4
  title = build_page(cuke_sniffer, "title.html.erb")
5
- legend = build_page(cuke_sniffer, "legend.html.erb")
5
+ information = build_page(cuke_sniffer, "information.html.erb")
6
6
  summary = build_page(cuke_sniffer, "summary.html.erb")
7
7
  rules = rules_template(cuke_sniffer)
8
8
  improvement_list = build_page(cuke_sniffer, "improvement_list.html.erb")
9
+ dead_steps = build_page(cuke_sniffer, "dead_steps_min.html.erb")
9
10
  %>
10
11
 
11
- <%= styles %>
12
- <%= scripts %>
13
- <%= title %>
14
- <%= summary %>
15
- <%= improvement_list %>
16
- <%= rules %>
12
+ <div class="container">
13
+ <%= styles %>
14
+ <%= scripts %>
15
+ <%= title %>
16
+ <%= information %>
17
+ <%= summary %>
18
+ <%= improvement_list %>
19
+ <%= rules %>
20
+ <%= dead_steps %>
21
+ </div>
@@ -1,71 +1,103 @@
1
- <div id="rulesTab" class="title" onclick="toggleById('rules', this);updateDisplayStatus(document.getElementById('rules_function_bar'));updateDivScroll('rules', 'rules_table');">
2
- Rules +
3
- </div>
4
-
5
- <div id="rules_function_bar" class="function_bar">
6
- <input type="button" class="function_button" value="Collapse All" onclick="collapseAll('rule_detail')" />
7
- <input type="button" class="function_button" value="Expand All" onclick="expandAll('rule_detail')" />
8
- </div>
9
-
10
- <div class="shrink_section" id="rules">
11
- <table id="rules_table" style="width: 100%" border="0" cellspacing="0">
12
- <% index = 0 %>
13
- <% cuke_sniffer.rules.each do |rule| %>
14
- <% if !rule.enabled %>
15
- <tr class="notes disabled_title_row" onclick="updateDisplayStatus(document.getElementById('rule_detail_<%=index%>'));updateDivScroll('rules', 'rules_table');">
16
- <% elsif index.odd? %>
17
- <tr class="notes blue_title_row" onclick="updateDisplayStatus(document.getElementById('rule_detail_<%=index%>'));updateDivScroll('rules', 'rules_table');">
18
- <% else %>
19
- <tr class="notes white_title_row" onclick="updateDisplayStatus(document.getElementById('rule_detail_<%=index%>'));updateDivScroll('rules', 'rules_table');">
20
- <% end %>
1
+ <div class="row">
2
+ <div class="panel panel-default">
3
+ <div id="rulesTab" class="panel-heading panel-title" data-toggle="collapse" data-target="#rules_data">
4
+ Rules <span class="glyphicon glyphicon-menu-down"></span>
5
+ </div>
21
6
 
22
- <td>
23
- <%= rule.phrase %>
24
- </td>
25
- </tr>
26
-
27
- <% if index.odd? %>
28
- <tr id="rule_detail_<%= index %>" class="colored_subsection blue_row rule_detail" style="display:none;">
29
- <% else %>
30
- <tr id="rule_detail_<%= index %>" class="colored_subsection white_row rule_detail" style="display:none;">
31
- <% end %>
32
- <td style="padding-left:8px;">
33
- <table border="0" cellspacing="0">
34
- <tr>
35
- <td>
36
- <b>Score:</b> <%= rule.score %>
37
- </td>
38
- </tr>
39
- <tr>
40
- <td>
41
- <b>Targets:</b> <%= rule.targets.to_s.gsub(/[\]\[\"]/, "") %>
42
- </td>
43
- </tr>
44
- <% unless rule.conditions.empty? %>
45
- <tr>
46
- <td>
47
- <b>Conditions:</b>
48
- <table style="padding-left: 4px;">
49
- <% rule.conditions.each do |condition_symbol, value| %>
50
- <tr>
51
- <td>
52
- <%= condition_symbol %>:
53
- </td>
54
- <td>
55
- <%= value %>
56
- </td>
57
- </tr>
58
- <% end %>
59
- </table>
60
- </td>
61
- </tr>
7
+ <div id="rules_data" class="panel-body collapse">
8
+ <span class="button-bar">
9
+ <%= build_page(cuke_sniffer, "expand_and_collapse_buttons.html.erb") %>
10
+ <div class="btn-group enable-bar">
11
+ <div id="enableAllRules" class="btn btn-default">
12
+ Enable All
13
+ </div>
14
+ <div id="disableAllRules" class="btn btn-default">
15
+ Disable All
16
+ </div>
17
+ </div>
18
+ <div id="ruleFilters" class="btn-group" data-toggle="buttons">
19
+ <div class="btn btn-default active">
20
+ <input type="checkbox" checked data-rule-type="feature"/>
21
+ <span class="full-page" title="Feature">Feature</span>
22
+ <span class="small-page" title="Feature">F.</span>
23
+ </div>
24
+ <div class="btn btn-default active">
25
+ <input type="checkbox" checked data-rule-type="background"/>
26
+ <span class="full-page" title="Background">Background</span>
27
+ <span class="small-page" title="Background">B.</span>
28
+ </div>
29
+ <div class="btn btn-default active">
30
+ <input type="checkbox" checked data-rule-type="scenario"/>
31
+ <span class="full-page" title="Scenario">Scenario</span>
32
+ <span class="small-page" title="Scenario">S.</span>
33
+ </div>
34
+ <div class="btn btn-default active">
35
+ <input type="checkbox" checked data-rule-type="stepdefinition"/>
36
+ <span class="full-page" title="Step Definition">Step Definition</span>
37
+ <span class="small-page" title="Step Definition">S. D.</span>
38
+ </div>
39
+ <div class="btn btn-default active">
40
+ <input type="checkbox" checked data-rule-type="hook"/>
41
+ <span class="full-page" title="Hook">Hook</span>
42
+ <span class="small-page" title="Hook">H</span>
43
+ </div>
44
+ </div>
45
+ </span>
46
+ <% cuke_sniffer.rules.each do |rule| %>
47
+ <div class="rule" data-rule-symbol="<%=rule.symbol%>"
48
+ <% rule.targets.each do |target| %>
49
+ rule-<%=target%>
62
50
  <% end %>
63
- </table>
64
- </td>
65
- </tr>
66
-
67
- <% index += 1 %>
68
- <% end %>
69
- </table>
51
+ >
52
+ <div>
53
+ <input type="checkbox"
54
+ <% if rule.enabled%>
55
+ checked="checked"
56
+ <% end %>
57
+ />
58
+ <span data-phrase><%=rule.phrase %></span>
59
+ </div>
60
+ <div class="details" style="display:none;">
61
+ <div class="well">
62
+ <div class="row">
63
+ <div class="col-md-3">
64
+ <b>Score:</b>
65
+ </div>
66
+ <div class="col-md-9">
67
+ <%= rule.score %>
68
+ </div>
69
+ </div>
70
+ <div class="row">
71
+ <div class="col-md-3">
72
+ <b>Targets:</b>
73
+ </div>
74
+ <div class="col-md-9" data-targets>
75
+ <%= rule.targets.to_s.gsub(/[\]\[\"]/, "") %>
76
+ </div>
77
+ </div>
78
+ <% unless rule.conditions.empty? %>
79
+ <div class="row conditions">
80
+ <div class="col-md-3">
81
+ <b>Conditions:</b>
82
+ </div>
83
+ <div class="col-md-9">
84
+ <% rule.conditions.each do |condition_symbol, value| %>
85
+ <div class="row well">
86
+ <div class="col-md-2">
87
+ <%= condition_symbol %>:
88
+ </div>
89
+ <div class="col-md-10" data-conditions>
90
+ <%= value %>
91
+ </div>
92
+ </div>
93
+ <% end %>
94
+ </div>
95
+ </div>
96
+ <% end %>
97
+ </div>
98
+ </div>
99
+ </div>
100
+ <% end %>
101
+ </div>
102
+ </div>
70
103
  </div>
71
- <br style="clear:both">
@@ -2,7 +2,7 @@
2
2
  styles = build_page(cuke_sniffer, "css.html.erb")
3
3
  scripts = build_page(cuke_sniffer, "js.html.erb")
4
4
  title = build_page(cuke_sniffer, "title.html.erb")
5
- legend = build_page(cuke_sniffer, "legend.html.erb")
5
+ information = build_page(cuke_sniffer, "information.html.erb")
6
6
  summary = build_page(cuke_sniffer, "summary.html.erb")
7
7
  rules = rules_template(cuke_sniffer)
8
8
  improvement_list = build_page(cuke_sniffer, "improvement_list.html.erb")
@@ -11,14 +11,18 @@
11
11
  step_definitions = build_page(cuke_sniffer, "step_definitions.html.erb")
12
12
  hooks = build_page(cuke_sniffer, "hooks.html.erb")
13
13
  %>
14
-
15
- <%= styles %>
16
- <%= scripts %>
17
- <%= title %>
18
- <%= summary %>
19
- <%= improvement_list %>
20
- <%= rules %>
21
- <%= dead_steps %>
22
- <%= features %>
23
- <%= step_definitions %>
24
- <%= hooks %>
14
+ <body class="container">
15
+ <div class="container">
16
+ <%= styles %>
17
+ <%= title %>
18
+ <%= information %>
19
+ <%= summary %>
20
+ <%= improvement_list %>
21
+ <%= rules %>
22
+ <%= dead_steps %>
23
+ <%= features %>
24
+ <%= step_definitions %>
25
+ <%= hooks %>
26
+ <%= scripts %>
27
+ </div>
28
+ </body>
@@ -1,68 +1,74 @@
1
- <div class="title" onclick="toggleById('step_definitions_data', this);updateDisplayStatus(document.getElementById('step_definition_function_bar'));updateDivScroll('step_definitions_data', 'step_definitions_table');">
2
- Step Definitions +
3
- </div>
1
+ <div class="row">
2
+ <div class="panel panel-default">
3
+ <div id="stepDefinitionTab" class="panel-heading panel-title" data-toggle="collapse" data-target="#step_definitions">
4
+ Step Definitions <span class="glyphicon glyphicon-menu-down"></span>
5
+ </div>
4
6
 
5
- <div id="step_definition_function_bar" class="function_bar">
6
- <input type="button" class="function_button" value="Collapse All" onclick="collapseAll('step_definition_detail')" />
7
- <input type="button" class="function_button" value="Expand All" onclick="expandAllShiftingRows('step_definition_detail')" />
8
- </div>
9
-
10
- <div class="new_sub_section" id="step_definitions_data">
11
- <% if cuke_sniffer.step_definitions.count == 0 %>
12
- <div class="empty_set_message">There were no Step Definitions to sniff in '<%= cuke_sniffer.step_definitions_location %>'!</div>
13
- <% elsif cuke_sniffer.step_definitions.count >= 1 && cuke_sniffer.summary[:step_definitions][:total_score] ==0 %>
14
- <div class="empty_set_message">Excellent! No smells found for Step Definitions!</div>
15
- <% end %>
16
- <table id="step_definitions_table" style="width:100%;" border="0" cellspacing="0">
17
- <% index = 0 %>
18
- <% cuke_sniffer.step_definitions.each do |step_definition| %>
19
- <% next if step_definition.score <= 0 %>
20
- <% if index.odd? %>
21
- <tr class="notes blue_title_row" onclick="updateDisplayStatus(document.getElementById('step_definition_detail_<%=index%>')); updateDivScroll('step_definitions_data', 'step_definitions_table');">
22
- <% else %>
23
- <tr class="notes white_title_row" onclick="updateDisplayStatus(document.getElementById('step_definition_detail_<%=index%>')); updateDivScroll('step_definitions_data', 'step_definitions_table');">
24
- <% end %>
25
- <td id="step_definition_score_<%= index %>" valign="top" style="width:1%; color: red">
26
- <%= step_definition.score %>
27
- </td>
28
- <td id="step_definition_regex_<%= index %>" style="text-indent: 2px;">
29
- /<%= step_definition.regex.to_s.gsub(/[(]\?-mix:/, "")[0...-1] %>/
30
- </td>
31
- <td id="step_definition_calls_<%= index %>" valign="top" style="text-align:right;width:8%;">
32
- <% if cuke_sniffer.cataloged? %>
33
- Call(s): <%= step_definition.calls.size %>
34
- <% else %>
35
- Not cataloged
36
- <% end %>
37
- </td>
38
- </tr>
39
-
40
- <% if index.odd? %>
41
- <tr id="step_definition_detail_<%= index %>" class="blue_row step_definition_detail" style="display: none;">
42
- <% else %>
43
- <tr id="step_definition_detail_<%= index %>" class="white_row step_definition_detail" style="display: none;">
44
- <% end %>
45
- <td colspan="2">
46
- <% SummaryHelper::sort_improvement_list(step_definition.rules_hash).each do |phrase, count| %>
47
- <div style="text-indent: 10px;">
48
- <div style="color:red; display:inline-block;">
49
- <%= count %>
7
+ <div id="step_definitions" class="panel-body collapse">
8
+ <span class="button-bar">
9
+ <%= build_page(cuke_sniffer, "expand_and_collapse_buttons.html.erb") %>
10
+ <div class="btn-group" data-toggle="buttons">
11
+ <div id="showDeadSteps" class="btn btn-default">
12
+ <input type="checkbox"/>Show Dead Steps
13
+ </div>
14
+ </div>
15
+ </span>
16
+ <% if cuke_sniffer.step_definitions.count == 0 %>
17
+ <div>
18
+ <div>There were no Step Definitions to sniff in '<%= cuke_sniffer.step_definitions_location %>'!</div>
19
+ </div>
20
+ <% elsif cuke_sniffer.step_definitions.count >= 1 && cuke_sniffer.summary[:step_definitions][:total_score] ==0 %>
21
+ <div>
22
+ <div>Excellent! No smells found for Step Definitions!</div>
23
+ </div>
24
+ <% else %>
25
+ <% cuke_sniffer.step_definitions.each do |step_definition| %>
26
+ <% next if step_definition.score == 0 %>
27
+ <div class="stepDefinition <%if step_definition.calls.size == 0%>deadStep<% end %>">
28
+ <div class="row">
29
+ <div class="col-md-12 title">
30
+ <div class="col-md-1 red" title="Total Score from this Step Definition file.">
31
+ <%= step_definition.score %>
32
+ </div>
33
+ <div class="col-md-11">
34
+ /<%= step_definition.regex.to_s.gsub(/[(]\?-mix:/, "")[0...-1] %>/
35
+ </div>
50
36
  </div>
51
- <div style="display:inline-block;">
52
- <%= phrase %>
37
+ <div class="details col-md-12" style="display: none;">
38
+ <div class="well">
39
+ <div class="row">
40
+ <div class="col-md-12 filename">
41
+ File: <a target="_blank" href="file:///<%= step_definition.location.gsub(/:\d+$/, "") %>" title="Note: Links to file on system this report was generated.">
42
+ <%= step_definition.location.gsub(cuke_sniffer.step_definitions_location, '') %>
43
+ </a>
44
+ </div>
45
+ <div class="col-md-12">
46
+ <% if cuke_sniffer.cataloged? %>
47
+ Call(s): <%= step_definition.calls.size %>
48
+ <% else %>
49
+ Not cataloged
50
+ <% end %>
51
+ </div>
52
+ </div>
53
+ <div class="row well">
54
+ <% SummaryHelper::sort_improvement_list(step_definition.rules_hash).each do |phrase, count| %>
55
+ <div class="row" data-improvement-row>
56
+ <div class="col-md-1 red" data-score>
57
+ <%= count %>
58
+ </div>
59
+ <div class="col-md-11" data-improvement="<%=phrase %>">
60
+ <%= phrase %>
61
+ </div>
62
+ </div>
63
+ <% end %>
64
+ </div>
65
+ </div>
53
66
  </div>
54
67
  </div>
55
- <% end %>
56
- </td>
57
- <td valign="top" style="text-align: right">
58
- <a href="file:///<%= step_definition.location.gsub(/:\d+$/, "") %>" title="Note: Links to file on system this report was generated.">
59
- <%= step_definition.location.gsub(cuke_sniffer.step_definitions_location, '') %>
60
- </a>
61
- </td>
62
- </tr>
68
+ </div>
69
+ <% end %>
70
+ <% end %>
63
71
 
64
- <% index += 1 %>
65
- <% end %>
66
- </table>
67
- </div>
68
- <br style="clear:both">
72
+ </div>
73
+ </div>
74
+ </div>