Commits

David Carr committed 9bedc35

make html report the default format

Comments (0)

Files changed (5)

src/main/groovy/us/carrclan/david/gradle/tag/TagReportPlugin.groovy

             task.source = { extension.sourceSets.collect {it.allSource} as Object[] }
             task.reports.all { Report report ->
                 report.conventionMapping.with {
-                    enabled = { report.name == "txt" }
+                    enabled = { report.name == "html" }
                     destination = { new File(extension.reportsDir, "tags.${report.name}") }
                 }
             }

src/test/groovy/us/carrclan/david/gradle/tag/TaglistPluginTest.groovy

         TagReportTask task = (TagReportTask) project.tasks.getByName("tagReport")
         assert task.source.collect {project.relativePath(it)} == []
         assert task.tags == []
-        assert task.reports.text.enabled
-        assert !task.reports.html.enabled
+        assert task.reports.html.enabled
+        assert !task.reports.text.enabled
         assert !task.reports.xml.enabled
         assert project.relativePath(task.reports.html.destination) == "build/reports/tags/tags.html"
         assert project.relativePath(task.reports.text.destination) == "build/reports/tags/tags.txt"
                 ["src/main/java/us/carrclan/david/gradle/tag/User.java"]
         task.execute()
         assert task.state.executed
-        assert project.file("build/reports/tags/tags.txt").text ==
-                getClass().getResource("report1.expected.txt").text
-        assert !project.file("build/reports/tags/tags.html").exists()
+
+        assert project.file("build/reports/tags/tags.html").text ==
+                getClass().getResource("report1.expected.html").text
+        assert !project.file("build/reports/tags/tags.txt").exists()
         assert !project.file("build/reports/tags/tags.xml").exists()
     }
 
         plugin.apply(project)
         project.apply plugin: "java"
         createSourceFiles1()
+        project.tagReport.tags = tagTypes1
+        TagReportTask task = (TagReportTask) project.tasks.getByName("tagReport")
+        task.reports.html.enabled = false
+        task.reports.text.enabled = true
+        task.reports.xml.enabled = true
+        task.execute()
+
+        assert !project.file("build/reports/tags/tags.html").exists()
+        assert project.file("build/reports/tags/tags.txt").text.trim() ==
+                getClass().getResource("report1.expected.txt").text.trim()
+        assert project.file("build/reports/tags/tags.xml").text.trim() ==
+                getClass().getResource("report1.expected.xml").text.trim()
+    }
+
+    @Test
+    void caseInsensitivity() {
+        plugin.apply(project)
+        project.apply plugin: "java"
+        createSourceFiles1()
         project.tagReport.tags = tagTypes2
         TagReportTask task = (TagReportTask) project.tasks.getByName("tagReport")
-        task.reports.text.enabled = false
         task.reports.html.enabled = true
+        task.reports.text.enabled = true
         task.reports.xml.enabled = true
         task.execute()
 
         assert project.file("build/reports/tags/tags.html").text.trim() ==
                 getClass().getResource("report2.expected.html").text.trim()
+        assert project.file("build/reports/tags/tags.txt").text.trim() ==
+                getClass().getResource("report2.expected.txt").text.trim()
         assert project.file("build/reports/tags/tags.xml").text.trim() ==
                 getClass().getResource("report2.expected.xml").text.trim()
-        assert !project.file("build/reports/tags/tags.txt").exists()
     }
 
     @Test

src/test/resources/us/carrclan/david/gradle/tag/report1.expected.html

+<html>
+    <head>
+        <title>Tag Report</title>
+        <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css"/>
+        <script src="http://code.jquery.com/jquery-1.9.0.js"></script>
+        <script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>
+        <style type="text/css">
+            body {
+                margin: 10px;
+            }
+            h1 {
+                font-size: 24px;
+                margin: 5px 0px;
+            }
+            .ui-styled-table {
+                border-collapse: collapse;
+            }
+            .ui-accordion .ui-accordion-content {
+                padding: 0;
+            }
+            th, td {
+                padding: 0.25em;
+            }
+            .details {
+                width: 100%;
+            }
+        </style>
+        <script>
+            jQuery(function() {
+                jQuery("#tabs").tabs();
+                jQuery("#type-details, #file-details").accordion({
+                    active: false,
+                    collapsible: true,
+                    heightStyle: "content"
+                });
+                jQuery.fn.styledTable = function () {
+                    return this.each(function () {
+                        var table = jQuery(this);
+                        table.addClass("ui-styled-table");
+                        table.find("th").addClass("ui-state-default");
+                        table.find("td").addClass("ui-widget-content");
+                    });
+                };
+                jQuery("table").styledTable();
+            });
+        </script>
+    </head>
+    <body>
+        <h1>Tag Report</h1>
+        <div id="tabs">
+            <ul>
+                <li><a href="#tab-by-type">By Type</a></li>
+                <li><a href="#tab-by-file">By File</a></li>
+            </ul>
+            <div id="tab-by-type">
+                <div id="type-details">
+                    <h3>TODO (3 matches)</h3>
+                    <div>
+                        <table class="details">
+                            <thead>
+                                <tr>
+                                    <th>Match</th>
+                                    <th>File</th>
+                                    <th>Line</th>
+                                    <th>Column</th>
+                                </tr>
+                            </thead>
+                            <tbody>
+                                <tr>
+                                    <td>TODO: add constructor</td>
+                                    <td>src/main/java/us/carrclan/david/gradle/tag/User.java</td>
+                                    <td>8</td>
+                                    <td>8</td>
+                                </tr>
+                                <tr>
+                                    <td>@todo use char[] for password instead of String</td>
+                                    <td>src/main/java/us/carrclan/david/gradle/tag/User.java</td>
+                                    <td>11</td>
+                                    <td>8</td>
+                                </tr>
+                                <tr>
+                                    <td>TODO: null handling</td>
+                                    <td>src/main/java/us/carrclan/david/gradle/tag/User.java</td>
+                                    <td>14</td>
+                                    <td>51</td>
+                                </tr>
+                            </tbody>
+                        </table>
+                    </div>
+                    <h3>XXX (1 match)</h3>
+                    <div>
+                        <table class="details">
+                            <thead>
+                                <tr>
+                                    <th>Match</th>
+                                    <th>File</th>
+                                    <th>Line</th>
+                                    <th>Column</th>
+                                </tr>
+                            </thead>
+                            <tbody>
+                                <tr>
+                                    <td>XXX: store a hash rather than the plaintext password</td>
+                                    <td>src/main/java/us/carrclan/david/gradle/tag/User.java</td>
+                                    <td>6</td>
+                                    <td>33</td>
+                                </tr>
+                            </tbody>
+                        </table>
+                    </div>
+                </div>
+            </div>
+            <div id="tab-by-file">
+                <div id="file-details">
+                    <h3>src/main/java/us/carrclan/david/gradle/tag/User.java (4 matches)</h3>
+                    <div>
+                        <table class="details">
+                            <thead>
+                                <tr>
+                                    <th>Match</th>
+                                    <th>Type</th>
+                                    <th>Line</th>
+                                    <th>Column</th>
+                                </tr>
+                            </thead>
+                            <tbody>
+                                <tr>
+                                    <td>XXX: store a hash rather than the plaintext password</td>
+                                    <td>XXX</td>
+                                    <td>6</td>
+                                    <td>33</td>
+                                </tr>
+                                <tr>
+                                    <td>TODO: add constructor</td>
+                                    <td>TODO</td>
+                                    <td>8</td>
+                                    <td>8</td>
+                                </tr>
+                                <tr>
+                                    <td>@todo use char[] for password instead of String</td>
+                                    <td>TODO</td>
+                                    <td>11</td>
+                                    <td>8</td>
+                                </tr>
+                                <tr>
+                                    <td>TODO: null handling</td>
+                                    <td>TODO</td>
+                                    <td>14</td>
+                                    <td>51</td>
+                                </tr>
+                            </tbody>
+                        </table>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </body>
+</html>

src/test/resources/us/carrclan/david/gradle/tag/report1.expected.xml

+<report>
+    <tag name="TODO">
+        <patterns>
+            <pattern>@todo</pattern>
+            <pattern>TODO</pattern>
+        </patterns>
+        <matches>
+            <match file="src/main/java/us/carrclan/david/gradle/tag/User.java" line="8" column="8">TODO: add constructor</match>
+            <match file="src/main/java/us/carrclan/david/gradle/tag/User.java" line="11" column="8">@todo use char[] for password instead of String</match>
+            <match file="src/main/java/us/carrclan/david/gradle/tag/User.java" line="14" column="51">TODO: null handling</match>
+        </matches>
+    </tag>
+    <tag name="XXX">
+        <patterns>
+            <pattern>XXX</pattern>
+        </patterns>
+        <matches>
+            <match file="src/main/java/us/carrclan/david/gradle/tag/User.java" line="6" column="33">XXX: store a hash rather than the plaintext password</match>
+        </matches>
+    </tag>
+</report>

src/test/resources/us/carrclan/david/gradle/tag/report2.expected.txt

+Summary
+------------------------------------------------------------
+TODO: 3
+XXX: 1
+
+TODO
+------------------------------------------------------------
+src/main/java/us/carrclan/david/gradle/tag/User.java:8:8: TODO: add constructor
+src/main/java/us/carrclan/david/gradle/tag/User.java:11:9: todo use char[] for password instead of String
+src/main/java/us/carrclan/david/gradle/tag/User.java:14:51: TODO: null handling
+
+XXX
+------------------------------------------------------------
+src/main/java/us/carrclan/david/gradle/tag/User.java:6:33: XXX: store a hash rather than the plaintext password
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.