Skip to content

Commit

Permalink
[core] Add support for ConcurrentHashMap in
Browse files Browse the repository at this point in the history
AbstractAsKeyOfSetOrMap

Fixes #1329

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=263039480
  • Loading branch information
blemale authored and netdpb committed Aug 16, 2019
1 parent 5c0f77f commit 2453670
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public abstract class AbstractAsKeyOfSetOrMap extends BugChecker
.onClass("com.google.common.collect.Maps")
.named("newLinkedHashMap"),
Matchers.constructor().forClass("java.util.LinkedHashMap"),
Matchers.constructor().forClass("java.util.concurrent.ConcurrentHashMap"),
MethodMatchers.staticMethod()
.onClass("com.google.common.collect.HashBiMap")
.named("create"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public void positive() {
"import java.util.Set;",
"import java.util.Map;",
"import java.util.LinkedHashMap;",
"import java.util.concurrent.ConcurrentHashMap;",
"import com.google.common.collect.Sets;",
"import com.google.common.collect.Maps;",
"import com.google.common.collect.HashMultiset;",
Expand Down Expand Up @@ -94,6 +95,9 @@ public void positive() {
" LinkedHashMap<String[], Integer> testLinkedHashMap"
+ "= new LinkedHashMap<String[], Integer>();",
" // BUG: Diagnostic contains: ArrayAsKeyOfSetOrMap",
" ConcurrentHashMap<String[], Integer> testConcurrentHashMap"
+ "= new ConcurrentHashMap<String[], Integer>();",
" // BUG: Diagnostic contains: ArrayAsKeyOfSetOrMap",
" HashMultiset<String[]> testHashMultiSet = HashMultiset.create();",
" // BUG: Diagnostic contains: ArrayAsKeyOfSetOrMap",
" LinkedHashMultiset<String[]> testLinkedHashMultiSet"
Expand All @@ -112,6 +116,7 @@ public void negative() {
"import java.util.Set;",
"import java.util.Map;",
"import java.util.LinkedHashMap;",
"import java.util.concurrent.ConcurrentHashMap;",
"import com.google.common.collect.Sets;",
"import com.google.common.collect.Maps;",
"import java.util.HashMap;",
Expand Down Expand Up @@ -147,6 +152,8 @@ public void negative() {
" HashBiMap<String, Integer> testHashBiMap = HashBiMap.create();",
" LinkedHashMap<String, Integer> testLinkedHashMap"
+ "= new LinkedHashMap<String, Integer>();",
" ConcurrentHashMap<String, Integer> testConcurrentHashMap"
+ "= new ConcurrentHashMap<String, Integer>();",
" HashMultiset<String> testHashMultiSet = HashMultiset.create();",
" LinkedHashMultiset<String> testLinkedHashMultiSet"
+ "= LinkedHashMultiset.create();",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public void positive() {
"import java.util.HashMap;",
"import java.util.HashSet;",
"import java.util.Collection;",
"import java.util.concurrent.ConcurrentHashMap;",
"import com.google.common.collect.Sets;",
"import com.google.common.collect.Maps;",
"import com.google.common.collect.HashMultiset;",
Expand Down Expand Up @@ -97,6 +98,9 @@ public void positive() {
" LinkedHashMap<TestProtoMessage, Integer> testLinkedHashMap"
+ "= new LinkedHashMap<TestProtoMessage, Integer>();",
" // BUG: Diagnostic contains: ProtosAsKeyOfSetOrMap",
" ConcurrentHashMap<TestProtoMessage, Integer> testConcurrentHashMap"
+ "= new ConcurrentHashMap<TestProtoMessage, Integer>();",
" // BUG: Diagnostic contains: ProtosAsKeyOfSetOrMap",
" LinkedHashMultiset<TestProtoMessage> testLinkedHashMultiSet"
+ "= LinkedHashMultiset.create();",
" // BUG: Diagnostic contains: ProtosAsKeyOfSetOrMap",
Expand All @@ -115,6 +119,7 @@ public void negative() {
"import java.util.Set;",
"import java.util.Map;",
"import java.util.LinkedHashMap;",
"import java.util.concurrent.ConcurrentHashMap;",
"import com.google.common.collect.Sets;",
"import com.google.common.collect.Maps;",
"import java.util.HashMap;",
Expand Down Expand Up @@ -150,6 +155,8 @@ public void negative() {
" HashBiMap<String, Integer> testHashBiMap = HashBiMap.create();",
" LinkedHashMap<String, Integer> testLinkedHashMap"
+ "= new LinkedHashMap<String, Integer>();",
" ConcurrentHashMap<String, Integer> testConcurrentHashMap"
+ "= new ConcurrentHashMap<String, Integer>();",
" HashMultiset<String> testHashMultiSet = HashMultiset.create();",
" LinkedHashMultiset<String> testLinkedHashMultiSet"
+ "= LinkedHashMultiset.create();",
Expand Down

0 comments on commit 2453670

Please sign in to comment.