View Javadoc
1   /*
2    * Copyright (c) 2011-2024 Qulice.com
3    *
4    * All rights reserved.
5    *
6    * Redistribution and use in source and binary forms, with or without
7    * modification, are permitted provided that the following conditions
8    * are met: 1) Redistributions of source code must retain the above
9    * copyright notice, this list of conditions and the following
10   * disclaimer. 2) Redistributions in binary form must reproduce the above
11   * copyright notice, this list of conditions and the following
12   * disclaimer in the documentation and/or other materials provided
13   * with the distribution. 3) Neither the name of the Qulice.com nor
14   * the names of its contributors may be used to endorse or promote
15   * products derived from this software without specific prior written
16   * permission.
17   *
18   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
20   * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21   * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22   * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23   * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29   * OF THE POSSIBILITY OF SUCH DAMAGE.
30   */
31  package com.qulice.pmd;
32  
33  import java.io.Writer;
34  import java.util.List;
35  import net.sourceforge.pmd.Report;
36  import net.sourceforge.pmd.properties.AbstractPropertySource;
37  import net.sourceforge.pmd.renderers.Renderer;
38  import net.sourceforge.pmd.util.datasource.DataSource;
39  
40  /**
41   * Renderer implementation which keeps track of all pmd-generated report.
42   *
43   * @since 1.0
44   */
45  @SuppressWarnings("deprecation")
46  final class PmdRenderer extends AbstractPropertySource implements Renderer {
47      /**
48       * This variable is union of all observed reports.
49       */
50      private final Report accumulator = new Report();
51  
52      @Override
53      public String getName() {
54          return "qulice";
55      }
56  
57      @Override
58      public void setName(final String name) {
59          throw new UnsupportedOperationException("Unimplemented method 'setName'");
60      }
61  
62      @Override
63      public String getDescription() {
64          return "not implemented yet";
65      }
66  
67      @Override
68      public String defaultFileExtension() {
69          throw new UnsupportedOperationException("Unimplemented defaultFileExtension");
70      }
71  
72      @Override
73      public void setDescription(final String description) {
74          throw new UnsupportedOperationException("Unimplemented setDescription");
75      }
76  
77      @Override
78      public boolean isShowSuppressedViolations() {
79          throw new UnsupportedOperationException("Unimplemented isShowSuppressedViolations");
80      }
81  
82      @Override
83      public void setShowSuppressedViolations(final boolean show) {
84          throw new UnsupportedOperationException("Unimplemented setShowSuppressedViolations");
85      }
86  
87      @Override
88      public void setUseShortNames(final List<String> list) {
89          // ignore it
90      }
91  
92      @Override
93      public Writer getWriter() {
94          throw new UnsupportedOperationException("Unimplemented getWriter");
95      }
96  
97      @Override
98      public void setWriter(final Writer writer) {
99          throw new UnsupportedOperationException("Unimplemented setWriter");
100     }
101 
102     @Override
103     public void start() {
104         // ignore it
105     }
106 
107     @Override
108     public void startFileAnalysis(final DataSource source) {
109         // ignore it
110     }
111 
112     @Override
113     public void renderFileReport(final Report report) {
114         this.accumulator.merge(report);
115     }
116 
117     @Override
118     public void end() {
119         // ignore it
120     }
121 
122     @Override
123     public void flush() {
124         // ignore it
125     }
126 
127     @Override
128     public void setReportFile(final String report) {
129         // ignore it
130     }
131 
132     @Override
133     public String getPropertySourceType() {
134         throw new UnsupportedOperationException("Unimplemented method 'getPropertySourceType'");
135     }
136 
137     /**
138      * Merges all collected errors into the provided target.
139      * @param target A Report instance which is updated
140      */
141     void exportTo(final Report target) {
142         target.merge(this.accumulator);
143     }
144 }