Skip to content

Commit 67abc92

Browse files
committed
修复checkstyle检查出来的部分代码问题
1 parent 97d6f90 commit 67abc92

File tree

21 files changed

+217
-138
lines changed

21 files changed

+217
-138
lines changed

quality-checks/google_checks.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<property name="allowNonPrintableEscapes" value="true"/>
4141
</module>
4242
<module name="LineLength">
43-
<property name="max" value="100"/>
43+
<property name="max" value="120"/>
4444
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
4545
</module>
4646
<module name="AvoidStarImport"/>
@@ -52,7 +52,7 @@
5252
</module>
5353
<module name="NeedBraces"/>
5454
<module name="LeftCurly">
55-
<property name="maxLineLength" value="100"/>
55+
<property name="maxLineLength" value="120"/>
5656
</module>
5757
<module name="RightCurly">
5858
<property name="id" value="RightCurlySame"/>

weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java

Lines changed: 69 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
import java.util.Map;
55

66
/**
7-
* 微信开发所使用到的常量类
7+
* 微信开发所使用到的常量类.
88
*
99
* @author chanjarster & binarywang
1010
*/
1111
public class WxConsts {
1212
/**
13-
* 微信推送过来的消息的类型,和发送给微信xml格式消息的消息类型
13+
* 微信推送过来的消息的类型,和发送给微信xml格式消息的消息类型.
1414
*/
1515
public static class XmlMsgType {
1616
public static final String TEXT = "text";
@@ -31,32 +31,65 @@ public static class XmlMsgType {
3131
}
3232

3333
/**
34-
* 主动发送消息(即客服消息)的消息类型
34+
* 主动发送消息(即客服消息)的消息类型.
3535
*/
3636
public static class KefuMsgType {
37-
public static final String TEXT = "text";//文本消息
38-
public static final String IMAGE = "image";//图片消息
39-
public static final String VOICE = "voice";//语音消息
40-
public static final String VIDEO = "video";//视频消息
41-
public static final String MUSIC = "music";//音乐消息
42-
public static final String NEWS = "news";//图文消息(点击跳转到外链)
43-
public static final String MPNEWS = "mpnews";//图文消息(点击跳转到图文消息页面)
44-
public static final String FILE = "file";//发送文件(CP专用)
45-
public static final String TEXTCARD = "textcard";//文本卡片消息(CP专用)
46-
public static final String WXCARD = "wxcard";//卡券消息
37+
/**
38+
* 文本消息.
39+
*/
40+
public static final String TEXT = "text";
41+
/**
42+
* 图片消息.
43+
*/
44+
public static final String IMAGE = "image";
45+
/**
46+
* 语音消息.
47+
*/
48+
public static final String VOICE = "voice";
49+
/**
50+
* 视频消息.
51+
*/
52+
public static final String VIDEO = "video";
53+
/**
54+
* 音乐消息.
55+
*/
56+
public static final String MUSIC = "music";
57+
/**
58+
* 图文消息(点击跳转到外链).
59+
*/
60+
public static final String NEWS = "news";
61+
/**
62+
* 图文消息(点击跳转到图文消息页面).
63+
*/
64+
public static final String MPNEWS = "mpnews";
65+
/**
66+
* 发送文件(CP专用).
67+
*/
68+
public static final String FILE = "file";
69+
/**
70+
* 文本卡片消息(CP专用).
71+
*/
72+
public static final String TEXTCARD = "textcard";
73+
/**
74+
* 卡券消息.
75+
*/
76+
public static final String WXCARD = "wxcard";
77+
/**
78+
* 转发到客服的消息.
79+
*/
4780
public static final String TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service";
4881
}
4982

5083
/**
51-
* 表示是否是保密消息,0表示否,1表示是,默认0
84+
* 表示是否是保密消息,0表示否,1表示是,默认0.
5285
*/
5386
public static class KefuMsgSafe {
5487
public static final String NO = "0";
5588
public static final String YES = "1";
5689
}
5790

5891
/**
59-
* 群发消息的消息类型
92+
* 群发消息的消息类型.
6093
*/
6194
public static class MassMsgType {
6295
public static final String MPNEWS = "mpnews";
@@ -67,7 +100,7 @@ public static class MassMsgType {
67100
}
68101

69102
/**
70-
* 群发消息后微信端推送给服务器的反馈消息
103+
* 群发消息后微信端推送给服务器的反馈消息.
71104
*/
72105
public static class MassMsgStatus {
73106
public static final String SEND_SUCCESS = "send success";
@@ -83,7 +116,7 @@ public static class MassMsgStatus {
83116
public static final String ERR_21000 = "err(21000)";
84117

85118
/**
86-
* 群发反馈消息代码所对应的文字描述
119+
* 群发反馈消息代码所对应的文字描述.
87120
*/
88121
public static final Map<String, String> STATUS_DESC = new HashMap<>();
89122

@@ -103,7 +136,7 @@ public static class MassMsgStatus {
103136
}
104137

105138
/**
106-
* 微信端推送过来的事件类型
139+
* 微信端推送过来的事件类型.
107140
*/
108141
public static class EventType {
109142
public static final String SUBSCRIBE = "subscribe";
@@ -124,7 +157,7 @@ public static class EventType {
124157
}
125158

126159
/**
127-
* 上传多媒体(临时素材)文件的类型
160+
* 上传多媒体(临时素材)文件的类型.
128161
*/
129162
public static class MediaFileType {
130163
public static final String IMAGE = "image";
@@ -135,78 +168,78 @@ public static class MediaFileType {
135168
}
136169

137170
/**
138-
* 自定义菜单的按钮类型
171+
* 自定义菜单的按钮类型.
139172
*/
140173
public static class MenuButtonType {
141174
/**
142-
* 点击推事件
175+
* 点击推事件.
143176
*/
144177
public static final String CLICK = "click";
145178
/**
146-
* 跳转URL
179+
* 跳转URL.
147180
*/
148181
public static final String VIEW = "view";
149182
/**
150-
* 跳转到小程序
183+
* 跳转到小程序.
151184
*/
152185
public static final String MINIPROGRAM = "miniprogram";
153186
/**
154-
* 扫码推事件
187+
* 扫码推事件.
155188
*/
156189
public static final String SCANCODE_PUSH = "scancode_push";
157190
/**
158-
* 扫码推事件且弹出“消息接收中”提示框
191+
* 扫码推事件且弹出“消息接收中”提示框.
159192
*/
160193
public static final String SCANCODE_WAITMSG = "scancode_waitmsg";
161194
/**
162-
* 弹出系统拍照发图
195+
* 弹出系统拍照发图.
163196
*/
164197
public static final String PIC_SYSPHOTO = "pic_sysphoto";
165198
/**
166-
* 弹出拍照或者相册发图
199+
* 弹出拍照或者相册发图.
167200
*/
168201
public static final String PIC_PHOTO_OR_ALBUM = "pic_photo_or_album";
169202
/**
170-
* 弹出微信相册发图器
203+
* 弹出微信相册发图器.
171204
*/
172205
public static final String PIC_WEIXIN = "pic_weixin";
173206
/**
174-
* 弹出地理位置选择器
207+
* 弹出地理位置选择器.
175208
*/
176209
public static final String LOCATION_SELECT = "location_select";
177210
/**
178-
* 下发消息(除文本消息)
211+
* 下发消息(除文本消息).
179212
*/
180213
public static final String MEDIA_ID = "media_id";
181214
/**
182-
* 跳转图文消息URL
215+
* 跳转图文消息URL.
183216
*/
184217
public static final String VIEW_LIMITED = "view_limited";
185218
}
186219

187220
/**
188-
* oauth2网页授权的scope
221+
* oauth2网页授权的scope.
189222
*/
190223
public static class OAuth2Scope {
191224
/**
192-
* 不弹出授权页面,直接跳转,只能获取用户openid
225+
* 不弹出授权页面,直接跳转,只能获取用户openid.
193226
*/
194227
public static final String SNSAPI_BASE = "snsapi_base";
195228
/**
196-
* 弹出授权页面,可通过openid拿到昵称、性别、所在地。并且,即使在未关注的情况下,只要用户授权,也能获取其信息
229+
* 弹出授权页面,可通过openid拿到昵称、性别、所在地。并且,即使在未关注的情况下,只要用户授权,也能获取其信息.
197230
*/
198231
public static final String SNSAPI_USERINFO = "snsapi_userinfo";
199232
}
200233

201234
/**
202-
* 网页应用登录授权作用域
235+
* 网页应用登录授权作用域.
203236
*/
204237
public static class QrConnectScope {
205238
public static final String SNSAPI_LOGIN = "snsapi_login";
206239
}
207240

208241
/**
209-
* 永久素材类型
242+
* 永久素材类型.
210243
*/
211244
public static class MaterialType {
212245
public static final String NEWS = "news";

weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxErrorExceptionHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import me.chanjar.weixin.common.exception.WxErrorException;
44

55
/**
6-
* WxErrorException处理器
6+
* WxErrorException处理器.
77
*/
88
public interface WxErrorExceptionHandler {
99

weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageDuplicateChecker.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@
22

33
/**
44
* <pre>
5-
* 消息重复检查器
5+
* 消息重复检查器.
66
* 微信服务器在五秒内收不到响应会断掉连接,并且重新发起请求,总共重试三次
77
* </pre>
88
*/
99
public interface WxMessageDuplicateChecker {
1010

1111
/**
12+
* 判断消息是否重复.
1213
* <h2>公众号的排重方式</h2>
13-
* <p>
14+
*
1415
* <p>普通消息:关于重试的消息排重,推荐使用msgid排重。<a href="http://mp.weixin.qq.com/wiki/10/79502792eef98d6e0c6e1739da387346.html">文档参考</a>。</p>
1516
* <p>事件消息:关于重试的消息排重,推荐使用FromUserName + CreateTime 排重。<a href="http://mp.weixin.qq.com/wiki/2/5baf56ce4947d35003b86a9805634b1e.html">文档参考</a></p>
16-
* <p>
17+
*
1718
* <h2>企业号的排重方式</h2>
18-
* <p>
19-
* 官方文档完全没有写,参照公众号的方式排重。
20-
* <p>
19+
* <p>官方文档完全没有写,参照公众号的方式排重。</p>
2120
* <p>或者可以采取更简单的方式,如果有MsgId就用MsgId排重,如果没有就用FromUserName+CreateTime排重</p>
2221
*
2322
* @param messageId messageId需要根据上面讲的方式构造

weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInMemoryDuplicateChecker.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,46 @@
66

77
/**
88
* <pre>
9-
* 默认消息重复检查器
9+
* 默认消息重复检查器.
1010
* 将每个消息id保存在内存里,每隔5秒清理已经过期的消息id,每个消息id的过期时间是15秒
1111
* </pre>
1212
*/
1313
public class WxMessageInMemoryDuplicateChecker implements WxMessageDuplicateChecker {
1414

1515
/**
16-
* 一个消息ID在内存的过期时间:15秒
16+
* 一个消息ID在内存的过期时间:15秒.
1717
*/
1818
private final Long timeToLive;
1919

2020
/**
21-
* 每隔多少周期检查消息ID是否过期:5秒
21+
* 每隔多少周期检查消息ID是否过期:5秒.
2222
*/
2323
private final Long clearPeriod;
2424

2525
/**
26-
* 消息id->消息时间戳的map
26+
* 消息id->消息时间戳的map.
2727
*/
2828
private final ConcurrentHashMap<String, Long> msgId2Timestamp = new ConcurrentHashMap<>();
2929

3030
/**
31-
* 后台清理线程是否已经开启
31+
* 后台清理线程是否已经开启.
3232
*/
3333
private final AtomicBoolean backgroundProcessStarted = new AtomicBoolean(false);
3434

3535
/**
36-
* WxMsgIdInMemoryDuplicateChecker构造函数
36+
* 无参构造方法.
3737
* <pre>
3838
* 一个消息ID在内存的过期时间:15秒
3939
* 每隔多少周期检查消息ID是否过期:5秒
4040
* </pre>
4141
*/
4242
public WxMessageInMemoryDuplicateChecker() {
43-
this.timeToLive = 15 * 1000l;
44-
this.clearPeriod = 5 * 1000l;
43+
this.timeToLive = 15 * 1000L;
44+
this.clearPeriod = 5 * 1000L;
4545
}
4646

4747
/**
48-
* WxMsgIdInMemoryDuplicateChecker构造函数
48+
* 构造方法.
4949
*
5050
* @param timeToLive 一个消息ID在内存的过期时间:毫秒
5151
* @param clearPeriod 每隔多少周期检查消息ID是否过期:毫秒
@@ -66,7 +66,8 @@ public void run() {
6666
while (true) {
6767
Thread.sleep(WxMessageInMemoryDuplicateChecker.this.clearPeriod);
6868
Long now = System.currentTimeMillis();
69-
for (Map.Entry<String, Long> entry : WxMessageInMemoryDuplicateChecker.this.msgId2Timestamp.entrySet()) {
69+
for (Map.Entry<String, Long> entry :
70+
WxMessageInMemoryDuplicateChecker.this.msgId2Timestamp.entrySet()) {
7071
if (now - entry.getValue() > WxMessageInMemoryDuplicateChecker.this.timeToLive) {
7172
WxMessageInMemoryDuplicateChecker.this.msgId2Timestamp.entrySet().remove(entry);
7273
}

weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/menu/WxMenu.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import java.util.List;
1212

1313
/**
14-
* 菜单(公众号和企业号共用的)
14+
* 菜单(公众号和企业号共用的).
1515
*
1616
* @author Daniel Qian
1717
*/
@@ -36,7 +36,8 @@ public static WxMenu fromJson(String json) {
3636
* 相比 http://mp.weixin.qq.com/wiki/13/43de8269be54a0a6f64413e4dfa94f39.html 的格式,外层多套了一个menu
3737
*/
3838
public static WxMenu fromJson(InputStream is) {
39-
return WxGsonBuilder.create().fromJson(new InputStreamReader(is, StandardCharsets.UTF_8), WxMenu.class);
39+
return WxGsonBuilder.create()
40+
.fromJson(new InputStreamReader(is, StandardCharsets.UTF_8), WxMenu.class);
4041
}
4142

4243
public List<WxMenuButton> getButtons() {

0 commit comments

Comments
 (0)