Skip to content

Commit 2c04fd4

Browse files
committed
added findbugs to the build
1 parent abff3ab commit 2c04fd4

9 files changed

Lines changed: 122 additions & 22 deletions

File tree

findbugs-exclude.xml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<FindBugsFilter>
2+
3+
<Match>
4+
<Class name="ch.qos.logback.core.util.Loader" />
5+
<Bug pattern="DMI_COLLECTION_OF_URLS" />
6+
</Match>
7+
8+
<Match>
9+
<Class name="ch.qos.logback.core.encoder.LayoutWrappingEncoder" />
10+
<Bug pattern="DM_DEFAULT_ENCODING" />
11+
</Match>
12+
13+
<Match>
14+
<Class name="ch.qos.logback.core.net.SyslogAppenderBase" />
15+
<Bug pattern="DM_DEFAULT_ENCODING" />
16+
</Match>
17+
18+
<Match>
19+
<Class name="ch.qos.logback.core.util.FileUtil" />
20+
<Bug pattern="DM_DEFAULT_ENCODING" />
21+
</Match>
22+
23+
<Match>
24+
<Class name="ch.qos.logback.classic.net.SyslogAppender" />
25+
<Bug pattern="DM_DEFAULT_ENCODING" />
26+
</Match>
27+
28+
<Match>
29+
<Class name="ch.qos.logback.classic.net.JMSQueueSink" />
30+
<Bug pattern="DM_DEFAULT_ENCODING" />
31+
</Match>
32+
33+
<Match>
34+
<Class name="ch.qos.logback.classic.net.JMSTopicSink" />
35+
<Bug pattern="DM_DEFAULT_ENCODING" />
36+
</Match>
37+
38+
<Match>
39+
<Class name="ch.qos.logback.access.servlet.TeeHttpServletRequest" />
40+
<Bug pattern="DM_DEFAULT_ENCODING" />
41+
</Match>
42+
43+
<Match>
44+
<Class name="ch.qos.logback.access.servlet.TeeHttpServletResponse" />
45+
<Bug pattern="DM_DEFAULT_ENCODING" />
46+
</Match>
47+
48+
<Match>
49+
<Class name="ch.qos.logback.access.spi.AccessEvent" />
50+
<Bug pattern="DM_DEFAULT_ENCODING" />
51+
</Match>
52+
53+
<Match>
54+
<Class name="ch.qos.logback.access.spi.Util" />
55+
<Bug pattern="DM_DEFAULT_ENCODING" />
56+
</Match>
57+
58+
59+
<Match>
60+
<Class name="~chapters.*" />
61+
</Match>
62+
63+
<!-- ========= Safely ignorable ====== -->
64+
65+
<Match>
66+
<Class name="ch.qos.logback.core.encoder.EchoEncoder" />
67+
<Bug pattern="DM_DEFAULT_ENCODING" />
68+
</Match>
69+
70+
</FindBugsFilter>
71+

logback-access/src/main/java/ch/qos/logback/access/pattern/EnsureLineSeparation.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ public class EnsureLineSeparation implements PostCompileProcessor<IAccessEvent>
2525
* line.
2626
*/
2727
public void process(Converter<IAccessEvent> head) {
28+
if(head == null)
29+
throw new IllegalArgumentException("Empty converter chain");
30+
31+
// if head != null, then tail != null as well
2832
Converter<IAccessEvent> tail = ConverterUtil.findTail(head);
2933
Converter<IAccessEvent> newLineConverter = new LineSeparatorConverter();
30-
if (tail == null) {
31-
head = newLineConverter;
32-
} else {
33-
if (!(tail instanceof LineSeparatorConverter)) {
34+
if (!(tail instanceof LineSeparatorConverter)) {
3435
tail.setNext(newLineConverter);
35-
}
3636
}
3737
}
3838
}

logback-core/pom.xml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -176,18 +176,6 @@
176176
</instructions>
177177
</configuration>
178178
</plugin>
179-
180-
<plugin>
181-
<groupId>org.codehaus.mojo</groupId>
182-
<artifactId>findbugs-maven-plugin</artifactId>
183-
<version>${findbugs.version}</version>
184-
<configuration>
185-
<threshold>High</threshold>
186-
<!--<trace>true</trace>-->
187-
<!--<excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>-->
188-
</configuration>
189-
</plugin>
190-
191179
</plugins>
192180
</build>
193181

logback-core/src/main/java/ch/qos/logback/core/pattern/FormatInfo.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,15 @@ public boolean equals(Object o) {
139139
&& (leftTruncate == r.leftTruncate);
140140
}
141141

142+
@Override
143+
public int hashCode() {
144+
int result = min;
145+
result = 31 * result + max;
146+
result = 31 * result + (leftPad ? 1 : 0);
147+
result = 31 * result + (leftTruncate ? 1 : 0);
148+
return result;
149+
}
150+
142151
public String toString() {
143152
return "FormatInfo(" + min + ", " + max + ", " + leftPad + ", "
144153
+ leftTruncate + ")";

logback-core/src/main/java/ch/qos/logback/core/pattern/parser/CompositeNode.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public void setChildNode(Node childNode) {
3030
}
3131

3232
public boolean equals(Object o) {
33-
//System.out.println("CompositeNode.equals()");
3433
if(!super.equals(o)) {
3534
return false;
3635
}
@@ -42,8 +41,13 @@ public boolean equals(Object o) {
4241
return (childNode != null) ? childNode.equals(r.childNode)
4342
: (r.childNode == null);
4443
}
45-
46-
public String toString() {
44+
45+
@Override
46+
public int hashCode() {
47+
return super.hashCode();
48+
}
49+
50+
public String toString() {
4751
StringBuffer buf = new StringBuffer();
4852
if(childNode != null) {
4953
buf.append("CompositeNode("+childNode+")");

logback-core/src/main/java/ch/qos/logback/core/pattern/parser/FormattingNode.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,11 @@ public boolean equals(Object o) {
4848
return (formatInfo != null ? formatInfo.equals(r.formatInfo)
4949
: r.formatInfo == null);
5050
}
51+
52+
@Override
53+
public int hashCode() {
54+
int result = super.hashCode();
55+
result = 31 * result + (formatInfo != null ? formatInfo.hashCode() : 0);
56+
return result;
57+
}
5158
}

logback-core/src/main/java/ch/qos/logback/core/pattern/parser/Node.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,14 @@ public boolean equals(Object o) {
6767
&& (next != null ? next.equals(r.next) : r.next == null);
6868
}
6969

70-
String printNext() {
70+
@Override
71+
public int hashCode() {
72+
int result = type;
73+
result = 31 * result + (value != null ? value.hashCode() : 0);
74+
return result;
75+
}
76+
77+
String printNext() {
7178
if (next != null) {
7279
return " -> " + next;
7380
} else {

logback-core/src/main/java/ch/qos/logback/core/pattern/parser/SimpleKeywordNode.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public void setOptions(List<String> optionList) {
3636
}
3737

3838
public boolean equals(Object o) {
39-
// System.out.println("Keyword.equals()");
4039
if (!super.equals(o)) {
4140
return false;
4241
}
@@ -50,6 +49,11 @@ public boolean equals(Object o) {
5049
: r.optionList == null);
5150
}
5251

52+
@Override
53+
public int hashCode() {
54+
return super.hashCode();
55+
}
56+
5357
public String toString() {
5458
StringBuffer buf = new StringBuffer();
5559
if (optionList == null) {

pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,16 @@
320320
<version>2.15.2</version>
321321
</plugin>
322322

323+
<plugin>
324+
<groupId>org.codehaus.mojo</groupId>
325+
<artifactId>findbugs-maven-plugin</artifactId>
326+
<version>${findbugs.version}</version>
327+
<configuration>
328+
<threshold>High</threshold>
329+
<!--<trace>true</trace>-->
330+
<excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
331+
</configuration>
332+
</plugin>
323333

324334
<!-- ================ site plugin ==================== -->
325335
<plugin>

0 commit comments

Comments
 (0)