forked from alibaba/p3c
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
骏烈
committed
Oct 13, 2017
1 parent
f1e2331
commit a375ac4
Showing
306 changed files
with
23,554 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# Gradle | ||
build | ||
.gradle | ||
|
||
testdata/ | ||
# Java gitignore # | ||
.class | ||
.log | ||
|
||
# Package Files # | ||
|
||
*.war | ||
*.ear | ||
|
||
#hsf files | ||
configuration | ||
|
||
# maven gitignore# | ||
target/** | ||
|
||
.svn/ | ||
|
||
# intelliJ.gitignore # | ||
.idea | ||
*.iml | ||
*.ipr | ||
*.iws | ||
|
||
|
||
# Eclipse git ignore# | ||
*.pydevproject | ||
.project | ||
.metadata | ||
bin/** | ||
*/bin/** | ||
tmp/** | ||
tmp/**/* | ||
configuration/** | ||
*.tmp | ||
*.bak | ||
*.orig | ||
*.swp | ||
*~.nib | ||
.classpath | ||
.settings/ | ||
.loadpath | ||
.fileTable* | ||
.cache | ||
|
||
# External tool builders | ||
.externalToolBuilders/ | ||
|
||
# Locally stored "Eclipse launch configurations" | ||
*.launch | ||
|
||
# CDT-specific | ||
.cproject | ||
|
||
# PDT-specific | ||
.buildpath | ||
|
||
#log | ||
*.log | ||
*.log.* | ||
|
||
# Windows Thumbs.db | ||
*.db | ||
|
||
# OSX | ||
.DS_Store | ||
|
||
# sass gitignore# | ||
.sass-cache | ||
.idea | ||
|
||
# tcc_coverage | ||
coverage.ec | ||
|
||
|
||
|
||
config.client.* | ||
|
||
temp/ | ||
*.pid | ||
*.orig | ||
|
||
hsf.configuration/ | ||
|
||
# code coverage report | ||
*.ec | ||
|
||
#hsf test | ||
*.instance | ||
out | ||
!/p3c-idea/src/main/kotlin/com/alibaba/smartfox/work/tools/aone/ui/AoneBranchView.kt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,35 @@ | ||
## 代码规约插件全球首发 | ||
![倒计时_](https://gw.alicdn.com/tfscom/TB1il8pf6ihSKJjy0FeXXbJtpXa.jpg) | ||
10月14日杭州云栖大会上会,代码规约插件及源码,将在杭州云栖大会上[研发效能峰会](https://yunqi.aliyun.com/2017/hangzhou/meeting?day=day4&theme=all&meeting=detail1433 )的首发仪式上全球首发。 | ||
Java代码规约扫描插件已在[研发协同RDC](https://rdc-test.aliyun.com)(云效公有云解决方案)的测试功能中实现(设置->测试服务->阿里巴巴Java代码规约)。 | ||
|
||
过去的整整一年中,阿里内部经历过无数次针锋相对的讨论,与实战经验相结合,系统性地从编程,数据库,异常日志,工程结构,安全,单元测试(new)六个维度总结做为Java合格开发者必备的技术素养。只是文档让开发同学遵守是非常困难的,阿里研发一套自动检测插件——代码规约扫描插件,已在[研发协同RDC](https://rdc-test.aliyun.com/)(云效公有云解决方案)的实验室功能中实现。 | ||
# P3C | ||
|
||
[![alt text](https://gw.alicdn.com/tfscom/TB13OnghlUSMeJjy1zkXXaWmpXa.png "title")](https://rdc-test.aliyun.com) | ||
点图可在线扫描代码合规情况 | ||
[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) | ||
|
||
“开发手册”主要作者孤尽在10月13日的云栖大会上分享“从推动的Java的代码规约谈技术人成长的有所为”,欢迎大家到场零距离沟通。 | ||
## <font color="green">Preface</font> | ||
> We are pleased to present Alibaba Java Coding Guidelines, which consolidates the best programming practices over the years from Alibaba Group's technical teams. A vast number of Java programming teams impose demanding requirements on code quality across projects as we encourage reuse and better understanding of each other's programs. We have seen many programming problems in the past. For example, defective database table structures and index designs may cause software architecture flaws and performance risks. Yet as another example, confusing code structures make it difficult to maintain. Furthermore, vulnerable code without authentication is prone to hackers’ attacks. To address those kinds of problems, we developed this document for Java developers in Alibaba. | ||
For more information please refer the *Alibaba Java Coding Guidelines*: | ||
- 中文版: *[阿里巴巴Java开发手册](https://github.com/alibaba/p3c/blob/master/%E9%98%BF%E9%87%8C%E5%B7%B4%E5%B7%B4Java%E5%BC%80%E5%8F%91%E6%89%8B%E5%86%8C%EF%BC%88%E7%BB%88%E6%9E%81%E7%89%88%EF%BC%89.pdf)* | ||
- English Version: *[Alibaba Java Coding Guidelines](https://alibaba.github.io/Alibaba-Java-Coding-Guidelines)* | ||
|
||
电子工业出版社也将在一年后出版孤尽参与编写的“码出高效 - 阿里巴巴的Java开发手册详解”这本书。 | ||
## <font color="green">Introduction</font> | ||
The project consists of 3 parts: | ||
- [PMD implementations](p3c-pmd) | ||
- [IntelliJ IDEA plugin](idea-plugin) | ||
- [Eclipse plugin](eclipse-plugin) | ||
|
||
代码规约最新更新消息关注“代码规约”微信公众号: | ||
## <font color="green">Rules</font> | ||
<font color="blue">49 rules are realized based on PMD, please refer the P3C-PMD documentation for more detailed information. 4 rules implemented within IDE plugins (IDEA and Eclipse) as following:</font> | ||
|
||
![代码规约](https://gw.alicdn.com/tfscom/TB1x5WJaGmgSKJjSsphXXcy1VXa.jpg) | ||
- ``[Mandatory]`` Using a deprecated class or method is prohibited. | ||
Note: For example, decode(String source, String encode) should be used instead of the deprecated method decode(String encodeStr). Once an interface has been deprecated, the interface provider has the obligation to provide a new one. At the same time, client programmers have the obligation to check out what its new implementation is. | ||
|
||
- ``[Mandatory]`` An overridden method from an interface or abstract class must be marked with @Override annotation. | ||
Counter example: For getObject() and get0bject(), the first one has a letter 'O', and the second one has a number '0'. To accurately determine whether the overriding is successful, an @Override annotation is necessary. Meanwhile, once the method signature in the abstract class is changed, the implementation class will report a compile-time error immediately. | ||
|
||
- ``[Mandatory]`` A static field or method should be directly referred by its class name instead of its corresponding object name. | ||
|
||
- ``[Mandatory]`` The usage of hashCode and equals should follow: | ||
1. Override hashCode if equals is overridden. | ||
2. These two methods must be overridden for Set since they are used to ensure that no duplicate object will be inserted in Set. | ||
3. These two methods must be overridden if self-defined object is used as the key of Map. | ||
Note: String can be used as the key of Map since these two methods have been rewritten. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# Gradle | ||
build | ||
.gradle | ||
|
||
testdata/ | ||
# Java gitignore # | ||
.class | ||
.log | ||
|
||
# Package Files # | ||
|
||
*.war | ||
*.ear | ||
|
||
#hsf files | ||
configuration | ||
|
||
# maven gitignore# | ||
target/** | ||
|
||
.svn/ | ||
|
||
# intelliJ.gitignore # | ||
.idea | ||
*.iml | ||
*.ipr | ||
*.iws | ||
*.bat | ||
|
||
# Eclipse git ignore# | ||
*.pydevproject | ||
.project | ||
.metadata | ||
bin/** | ||
*/bin/** | ||
tmp/** | ||
tmp/**/* | ||
configuration/** | ||
*.tmp | ||
*.bak | ||
*.orig | ||
*.swp | ||
*~.nib | ||
.classpath | ||
.settings/ | ||
.loadpath | ||
.fileTable* | ||
.cache | ||
|
||
# External tool builders | ||
.externalToolBuilders/ | ||
|
||
# Locally stored "Eclipse launch configurations" | ||
*.launch | ||
|
||
# CDT-specific | ||
.cproject | ||
|
||
# PDT-specific | ||
.buildpath | ||
|
||
#log | ||
*.log | ||
*.log.* | ||
|
||
# Windows Thumbs.db | ||
*.db | ||
|
||
# OSX | ||
.DS_Store | ||
|
||
# sass gitignore# | ||
.sass-cache | ||
.idea | ||
|
||
# tcc_coverage | ||
coverage.ec | ||
|
||
|
||
|
||
config.client.* | ||
|
||
temp/ | ||
*.pid | ||
*.orig | ||
|
||
hsf.configuration/ | ||
|
||
# code coverage report | ||
*.ec | ||
|
||
#hsf test | ||
*.instance | ||
**/target | ||
.pmd | ||
**/.pmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Eclipse Plugin | ||
--- | ||
## <font color="green">Prepare</font> | ||
- Eclipse Juno+ | ||
- maven3.+ | ||
- JDK 1.7+ | ||
|
||
## <font color="green">Build</font> | ||
``` | ||
mvn -U clean install | ||
``` | ||
|
||
## <font color="green">Install</font> | ||
1. <font color="blue">Help >> Install New Software | ||
then enter this update site URL [https://p3c.alibaba.com/plugin/eclipse/update](https://p3c.alibaba.com/plugin/eclipse/update)</font> | ||
|
||
![Install Plugin](doc/images/install.png) | ||
|
||
2. <font color="blue">Follow the wizard, restart Eclipse to take effect after install success.</font> | ||
|
||
## <font color="green">Use</font> | ||
1. <font color="blue">Switch language</font> | ||
|
||
![Switch language](doc/images/eclipse_switch_language.png) | ||
|
||
2. <font color="blue">Code Analyze </font> | ||
|
||
![Analyze](doc/images/eclipse_analyze.png) | ||
|
||
![Analyze](doc/images/analyze_result.png) | ||
|
7 changes: 7 additions & 0 deletions
7
eclipse-plugin/com.alibaba.smartfox.eclipse.feature/build.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
bin.includes = feature.xml,\ | ||
feature.properties,\ | ||
smartfox.png | ||
src.includes = build.properties,\ | ||
feature.properties,\ | ||
feature.xml,\ | ||
smartfox.png |
26 changes: 26 additions & 0 deletions
26
eclipse-plugin/com.alibaba.smartfox.eclipse.feature/feature.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
feature.label = Ali-CodeAnalysis | ||
feature.provider_name = Alibaba | ||
feature.update_site_name = Alibaba IDE Portal | ||
|
||
description.text = Alibaba Java Coding Guidelines | ||
description.url = https://github.com/alibaba/p3c | ||
|
||
copyright.text =\ | ||
Copyright 2017 Alibaba Java Coding Guidelines | ||
|
||
license.url = https://github.com/alibaba/p3c | ||
license.text =\ | ||
Copyright 1999-2017 Alibaba Group. \n\ | ||
\n\ | ||
Licensed under the Apache License, Version 2.0 (the "License"); \n\ | ||
you may not use this file except in compliance with the License. \n\ | ||
You may obtain a copy of the License at \n\ | ||
\n\ | ||
http://www.apache.org/licenses/LICENSE-2.0 \n\ | ||
\n\ | ||
Unless required by applicable law or agreed to in writing, software \n\ | ||
distributed under the License is distributed on an "AS IS" BASIS, \n\ | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \n\ | ||
See the License for the specific language governing permissions and \n\ | ||
limitations under the License. \n\ | ||
|
46 changes: 46 additions & 0 deletions
46
eclipse-plugin/com.alibaba.smartfox.eclipse.feature/feature.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<feature | ||
id="com.alibaba.smartfox.eclipse.feature" | ||
label="%feature.label" | ||
version="1.0.0.qualifier" | ||
provider-name="%feature.provider_name" | ||
plugin="com.alibaba.smartfox.eclipse.plugin" | ||
image="smartfox.png"> | ||
|
||
<description url="%description.url"> | ||
Alibaba Java Coding Guidelines | ||
</description> | ||
|
||
<copyright> | ||
%copyright.text | ||
</copyright> | ||
|
||
<license url="%license.url"> | ||
%license.text | ||
</license> | ||
|
||
<url> | ||
<update label="%feature.update_site_name" url="https://p3c.alibaba.com/plugin/eclipse/update"/> | ||
</url> | ||
|
||
<requires> | ||
<import plugin="org.eclipse.ui"/> | ||
<import plugin="org.eclipse.core.runtime"/> | ||
<import plugin="org.eclipse.jdt.core"/> | ||
<import plugin="org.eclipse.ui.ide"/> | ||
<import plugin="org.eclipse.ui.views"/> | ||
<import plugin="org.eclipse.core.resources"/> | ||
<import plugin="org.eclipse.jface.text"/> | ||
<import plugin="org.eclipse.ui.workbench.texteditor"/> | ||
<import plugin="org.eclipse.ltk.core.refactoring"/> | ||
<import plugin="org.eclipse.jdt.ui"/> | ||
<import plugin="org.eclipse.core.filebuffers"/> | ||
</requires> | ||
|
||
<plugin | ||
id="com.alibaba.smartfox.eclipse.plugin" | ||
download-size="0" | ||
install-size="0" | ||
version="0.0.0"/> | ||
|
||
</feature> |
13 changes: 13 additions & 0 deletions
13
eclipse-plugin/com.alibaba.smartfox.eclipse.feature/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.alibaba.smartfox.eclipse</groupId> | ||
<artifactId>smartfox-eclipse</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>com.alibaba.smartfox.eclipse.feature</artifactId> | ||
<packaging>eclipse-feature</packaging> | ||
<inceptionYear>2017</inceptionYear> | ||
</project> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.