Skip to content
Permalink
Browse files

Merge branch 'findbugs' into spotbugs

 Conflicts:
	build.xml
	pom.xml
	src/main/java/com/mebigfatguy/fbcontrib/detect/WiringIssues.java
	src/main/java/com/mebigfatguy/fbcontrib/utils/BugType.java
  • Loading branch information
mebigfatguy committed Nov 17, 2019
2 parents da03b0d + 1bc5af3 commit 42a1c7e36bfb73f060784d0537ee04728e853c56
@@ -31,7 +31,7 @@
<property name="javac.debug" value="on" />
<property name="test_reports.dir" value="${target.dir}/reports/test"/>

<property name="sb-contrib.version" value="7.4.7" />
<property name="fb-contrib.version" value="7.4.8-SNAPSHOT" />

<property name="sonatype.dir" value="${user.home}/.sb-contrib-${sb-contrib.version}-sonatype" />

@@ -306,5 +306,6 @@
+0 BugPattern WEM_WEAK_EXCEPTION_MESSAGING
+0 BugPattern WI_DUPLICATE_WIRED_TYPES
+0 BugPattern WI_MANUALLY_ALLOCATING_AN_AUTOWIRED_BEAN
+0 BugPattern WI_WIRING_OF_STATIC_FIELD
+0 BugPattern WOC_WRITE_ONLY_COLLECTION_FIELD
+0 BugPattern WOC_WRITE_ONLY_COLLECTION_LOCAL
@@ -23,15 +23,15 @@

<!-- Detectors -->

<!-- COMMENT OUT FOR RELEASE
<!-- COMMENT OUT FOR RELEASE -->

<Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger" speed="fast"/>

<Detector class="com.mebigfatguy.fbcontrib.detect.BloatedSynchronizedBlock" speed="fast" reports="BSB_BLOATED_SYNCHRONIZED_BLOCK" hidden="true" />

<Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" />

COMMENT OUT FOR RELEASE -->
<!-- COMMENT OUT FOR RELEASE -->

<Detector class="com.mebigfatguy.fbcontrib.collect.CollectStatistics" speed="fast" reports="" hidden="true" />

@@ -302,7 +302,7 @@

<Detector class="com.mebigfatguy.fbcontrib.detect.BuryingLogic" speed="fast" reports="BL_BURYING_LOGIC"/>

<Detector class="com.mebigfatguy.fbcontrib.detect.WiringIssues" speed="fast" reports="WI_DUPLICATE_WIRED_TYPES,WI_MANUALLY_ALLOCATING_AN_AUTOWIRED_BEAN"/>
<Detector class="com.mebigfatguy.fbcontrib.detect.WiringIssues" speed="fast" reports="WI_DUPLICATE_WIRED_TYPES,WI_MANUALLY_ALLOCATING_AN_AUTOWIRED_BEAN,WI_WIRING_OF_STATIC_FIELD"/>

<Detector class="com.mebigfatguy.fbcontrib.detect.ConcurrentCollectionIssues" speed="fast" reports="CCI_CONCURRENT_COLLECTION_ISSUES_USE_PUT_IS_RACY"/>

@@ -332,11 +332,11 @@

<Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy" speed="slow" reports="CE_CLASS_ENVY" />

<!-- COMMENT OUT FOR POINT RELEASE
<!-- COMMENT OUT FOR POINT RELEASE -->

<Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousArgumentTypes" speed="fast" reports="SAT_SUSPICIOUS_ARGUMENT_TYPES" />

COMMENT OUT FOR POINT RELEASE -->
<!-- COMMENT OUT FOR POINT RELEASE -->

<!-- BugPattern -->

@@ -616,6 +616,7 @@
<BugPattern abbrev="BL" type="BL_BURYING_LOGIC" category="STYLE"/>
<BugPattern abbrev="WI" type="WI_DUPLICATE_WIRED_TYPES" category="CORRECTNESS"/>
<BugPattern abbrev="WI" type="WI_MANUALLY_ALLOCATING_AN_AUTOWIRED_BEAN" category="CORRECTNESS"/>
<BugPattern abbrev="WI" type="WI_WIRING_OF_STATIC_FIELD" category="CORRECTNESS"/>
<BugPattern abbrev="CCI" type="CCI_CONCURRENT_COLLECTION_ISSUES_USE_PUT_IS_RACY" category="CORRECTNESS"/>
<BugPattern abbrev="UTWR" type="UTWR_USE_TRY_WITH_RESOURCES" category="STYLE" experimental="true"/>
<BugPattern abbrev="SSCU" type="SSCU_SUSPICIOUS_SHADED_CLASS_USE" category="CORRECTNESS"/>
@@ -5950,6 +5950,19 @@ if (shouldCalcHalting && (calculateHaltingProbability() &gt; 0) { }
]]>
</Details>
</BugPattern>

<BugPattern type="WI_WIRING_OF_STATIC_FIELD">
<ShortDescription>Static field is autowired</ShortDescription>
<LongDescription>Static Field {1} is autowired</LongDescription>
<Details>
<![CDATA[
<p>Autowiring of static fields does not work using simple @Autowire annotations, not should you attempt to do
so as it's an anti pattern. Use PostConstruct methods to initialize static fields if you must do something
like this.</p>
]]>
</Details>

</BugPattern>

<BugPattern type="CCI_CONCURRENT_COLLECTION_ISSUES_USE_PUT_IS_RACY">
<ShortDescription>Method gets and sets a value of a ConcurrentHashMap in a racy manner</ShortDescription>
@@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.mebigfatguy.sb-contrib</groupId>
<artifactId>sb-contrib</artifactId>
<version>7.4.7</version>
<version>7.4.8-SNAPSHOT</version>

<!-- TODO: Oss parent is obsolete, define items directly for releasing -->
<parent>
@@ -124,6 +124,20 @@ public void visitClassContext(ClassContext classContext) {
}
}

@Override
public void visitField(Field obj) {
if (obj.isStatic()) {
for (AnnotationEntry entry : obj.getAnnotationEntries()) {
if (SPRING_AUTOWIRED.equals(entry.getAnnotationType())) {
bugReporter
.reportBug(new BugInstance(this, BugType.WI_WIRING_OF_STATIC_FIELD.name(), NORMAL_PRIORITY)
.addClass(this).addField(this));
break;
}
}
}
}

@Override
public void visitCode(Code obj) {
Method m = getMethod();
@@ -144,6 +144,7 @@
UTAO_TESTNG_ASSERTION_ODDITIES_NO_ASSERT, UTA_USE_TO_ARRAY, UVA_USE_VAR_ARGS, UTWR_USE_TRY_WITH_RESOURCES,

WEM_OBSCURING_EXCEPTION, WEM_WEAK_EXCEPTION_MESSAGING, WI_DUPLICATE_WIRED_TYPES,
WI_MANUALLY_ALLOCATING_AN_AUTOWIRED_BEAN, WOC_WRITE_ONLY_COLLECTION_FIELD, WOC_WRITE_ONLY_COLLECTION_LOCAL;
WI_MANUALLY_ALLOCATING_AN_AUTOWIRED_BEAN, WOC_WRITE_ONLY_COLLECTION_FIELD, WOC_WRITE_ONLY_COLLECTION_LOCAL,
WI_WIRING_OF_STATIC_FIELD,
// @formatter:on
}

0 comments on commit 42a1c7e

Please sign in to comment.
You can’t perform that action at this time.