未验证 提交 50bd12e9 编写于 作者: L Liang Zhang 提交者: GitHub

Add checkstyle template for CI check only (#3172)

* for checkstyle

* add checkstyle goal to maven validate

* skip autogen check
上级 23829483
......@@ -115,7 +115,7 @@
<cobertura-maven-plugin.version>2.7</cobertura-maven-plugin.version>
<jacoco.version>0.7.9</jacoco.version>
<findbugs-maven-plugin.version>3.0.2</findbugs-maven-plugin.version>
<maven-checkstyle-plugin.version>2.16</maven-checkstyle-plugin.version>
<maven-checkstyle-plugin.version>3.1.0</maven-checkstyle-plugin.version>
<maven-pmd-plugin.version>3.5</maven-pmd-plugin.version>
<frontend-maven-plugin.version>1.6</frontend-maven-plugin.version>
<jdepend-maven-plugin.version>2.0</jdepend-maven-plugin.version>
......@@ -664,6 +664,24 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
<configuration>
<configLocation>src/resources/checkstyle_ci.xml</configLocation>
<excludes>**/autogen/**/*</excludes>
</configuration>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
......@@ -825,7 +843,8 @@
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
<configuration>
<configLocation>src/resources/dd_checks.xml</configLocation>
<configLocation>src/resources/checkstyle.xml</configLocation>
<excludes>**/autogen/**/*</excludes>
</configuration>
</plugin>
<plugin>
......
......@@ -84,12 +84,12 @@ public final class GroupByMemoryMergedResult extends MemoryMergedResult {
if (!aggregationMap.containsKey(groupByValue)) {
Map<AggregationProjection, AggregationUnit> map = Maps.toMap(
selectSQLStatementContext.getProjectionsContext().getAggregationProjections(), new Function<AggregationProjection, AggregationUnit>() {
@Override
public AggregationUnit apply(final AggregationProjection input) {
return AggregationUnitFactory.create(input.getType());
}
});
@Override
public AggregationUnit apply(final AggregationProjection input) {
return AggregationUnitFactory.create(input.getType());
}
});
aggregationMap.put(groupByValue, map);
}
}
......
......@@ -110,6 +110,18 @@ public final class ProjectionsContextEngine {
|| containsItemInShorthandProjection(tablesContext, projections, orderByItemSegment) || containsProjection(projections, orderByItemSegment);
}
private boolean containsProjection(final Collection<Projection> projections, final OrderByItemSegment orderItem) {
for (Projection each : projections) {
if (orderItem instanceof IndexOrderByItemSegment) {
return true;
}
if (isSameAlias(each, (TextOrderByItemSegment) orderItem) || isSameQualifiedName(each, (TextOrderByItemSegment) orderItem)) {
return true;
}
}
return false;
}
private boolean containsItemInShorthandProjection(final TablesContext tablesContext, final Collection<Projection> projections, final OrderByItemSegment orderByItemSegment) {
return isUnqualifiedShorthandProjection(projections) || containsItemWithOwnerInShorthandProjections(tablesContext, projections, orderByItemSegment)
|| containsItemWithoutOwnerInShorthandProjections(tablesContext, projections, orderByItemSegment);
......@@ -175,18 +187,6 @@ public final class ProjectionsContextEngine {
return table.isPresent() && tableMetas.containsColumn(table.get().getName(), orderItem.getColumn().getName());
}
private boolean containsProjection(final Collection<Projection> projections, final OrderByItemSegment orderItem) {
for (Projection each : projections) {
if (orderItem instanceof IndexOrderByItemSegment) {
return true;
}
if (isSameAlias(each, (TextOrderByItemSegment) orderItem) || isSameQualifiedName(each, (TextOrderByItemSegment) orderItem)) {
return true;
}
}
return false;
}
private boolean isSameAlias(final Projection projection, final TextOrderByItemSegment orderItem) {
return projection.getAlias().isPresent() && (orderItem.getText().equalsIgnoreCase(projection.getAlias().get()) || orderItem.getText().equalsIgnoreCase(projection.getExpression()));
}
......
......@@ -18,8 +18,9 @@
package org.apache.shardingsphere.core.optimize.segment.insert.expression;
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
public final class DerivedParameterMarkerExpressionSegmentTest {
......
......@@ -22,7 +22,7 @@
<property name="severity" value="warning"/>
<property name="fileExtensions" value="java, properties, xml"/>
<module name="Header">
<property name="headerFile" value="copyright.txt"/>
<property name="headerFile" value="src/resources/copyright.txt"/>
<property name="fileExtensions" value="java"/>
</module>
<module name="FileTabCharacter">
......
<?xml version="1.0"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
<module name = "Checker">
<property name="charset" value="UTF-8"/>
<property name="severity" value="error"/>
<property name="fileExtensions" value="java, properties, xml"/>
<module name="Header">
<property name="headerFile" value="src/resources/copyright.txt"/>
<property name="fileExtensions" value="java"/>
</module>
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
</module>
<module name="FileLength"/>
<module name="NewlineAtEndOfFile">
<property name="lineSeparator" value="lf"/>
</module>
<module name="Translation"/>
<module name="UniqueProperties"/>
<module name="SeverityMatchFilter"/>
<module name="TreeWalker">
<!-- Naming Conventions -->
<module name="PackageName">
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
</module>
<module name="TypeName"/>
<module name="MethodName"/>
<module name="InterfaceTypeParameterName"/>
<module name="ClassTypeParameterName"/>
<module name="MethodTypeParameterName"/>
<module name="ConstantName"/>
<module name="StaticVariableName"/>
<module name="MemberName"/>
<module name="LocalVariableName"/>
<module name="LocalFinalVariableName"/>
<module name="ParameterName"/>
<module name="CatchParameterName"/>
<module name="AbbreviationAsWordInName">
<property name="allowedAbbreviationLength" value="6"/>
</module>
<!-- Size Violations -->
<module name="AnonInnerLength"/>
<module name="MethodLength"/>
<module name="LineLength">
<property name="max" value="200"/>
</module>
<module name="OuterTypeNumber"/>
<!-- Whitespace -->
<module name="EmptyForInitializerPad"/>
<module name="EmptyForIteratorPad"/>
<module name="MethodParamPad"/>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="NoLineWrap"/>
<module name="OperatorWrap"/>
<module name="SeparatorWrap">
<property name="id" value="SeparatorWrapDot"/>
<property name="tokens" value="DOT"/>
<property name="option" value="nl"/>
</module>
<module name="SeparatorWrap">
<property name="id" value="SeparatorWrapComma"/>
<property name="tokens" value="COMMA"/>
<property name="option" value="EOL"/>
</module>
<module name="SeparatorWrap">
<property name="id" value="SeparatorWrapEllipsis"/>
<property name="tokens" value="ELLIPSIS"/>
<property name="option" value="EOL"/>
</module>
<module name="SeparatorWrap">
<property name="id" value="SeparatorWrapArrayDeclarator"/>
<property name="tokens" value="ARRAY_DECLARATOR"/>
<property name="option" value="EOL"/>
</module>
<module name="SeparatorWrap">
<property name="id" value="SeparatorWrapMethodRef"/>
<property name="tokens" value="METHOD_REF"/>
<property name="option" value="nl"/>
</module>
<module name="GenericWhitespace"/>
<module name="NoWhitespaceBefore"/>
<module name="NoWhitespaceAfter"/>
<module name="WhitespaceAround"/>
<module name="WhitespaceAfter"/>
<module name="SingleSpaceSeparator"/>
<module name="EmptyLineSeparator">
<property name="allowMultipleEmptyLines" value="false"/>
<property name="allowMultipleEmptyLinesInsideClassMembers" value="false"/>
</module>
<!-- Imports -->
<module name="AvoidStarImport"/>
<module name="AvoidStaticImport">
<property name="excludes" value="org.junit.Assert.*,org.hamcrest.CoreMatchers.*,org.mockito.Mockito.*,org.mockito.ArgumentMatchers.*"/>
</module>
<module name="IllegalImport"/>
<module name="RedundantImport"/>
<module name="UnusedImports"/>
<module name="CustomImportOrder"/>
<!-- Annotations -->
<module name="AnnotationLocation">
<property name="id" value="AnnotationLocationMostCases"/>
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
</module>
<module name="AnnotationLocation">
<property name="id" value="AnnotationLocationVariables"/>
<property name="tokens" value="VARIABLE_DEF"/>
<property name="allowSamelineMultipleAnnotations" value="true"/>
</module>
<module name="AnnotationUseStyle"/>
<module name="MissingOverride"/>
<module name="SuppressWarnings"/>
<module name="MissingDeprecated"/>
<module name="SuppressWarningsHolder"/>
<!-- Modifiers -->
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>
<!-- Coding -->
<module name="ArrayTrailingComma"/>
<module name="CovariantEquals"/>
<module name="DefaultComesLast"/>
<module name="DeclarationOrder"/>
<module name="EmptyStatement"/>
<module name="EqualsAvoidNull"/>
<module name="ExplicitInitialization"/>
<module name="FallThrough"/>
<module name="IllegalInstantiation"/>
<module name="IllegalCatch"/>
<module name="IllegalThrows"/>
<module name="IllegalType">
<property name="tokens" value="METHOD_DEF,PARAMETER_DEF,VARIABLE_DEF"/>
</module>
<module name="IllegalTokenText">
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
<property name="format" value="\\u00(09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
<property name="message" value="Consider using special escape sequence instead of octal value or Unicode escaped value."/>
</module>
<module name="MissingSwitchDefault"/>
<module name="ModifiedControlVariable"/>
<module name="MultipleVariableDeclarations"/>
<module name="NestedIfDepth"/>
<module name="NestedTryDepth"/>
<module name="NoClone"/>
<module name="NoFinalizer"/>
<module name="SuperClone"/>
<module name="SuperFinalize"/>
<module name="OneStatementPerLine"/>
<module name="OverloadMethodsDeclarationOrder"/>
<module name="PackageDeclaration"/>
<module name="ParameterAssignment"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<module name="StringLiteralEquality"/>
<module name="UnnecessaryParentheses"/>
<module name="VariableDeclarationUsageDistance"/>
<!-- Block Checks -->
<module name="EmptyBlock"/>
<module name="EmptyCatchBlock">
<property name="exceptionVariableName" value="expected|ignore"/>
</module>
<module name="AvoidNestedBlocks"/>
<module name="NeedBraces"/>
<module name="LeftCurly"/>
<module name="RightCurly"/>
<!-- Class Design -->
<module name="FinalClass"/>
<!-- cannot recognize for lombok @NoArgsConstructor(access = AccessLevel.PRIVATE), just ignore -->
<!--<module name="HideUtilityClassConstructor"/>-->
<module name="OneTopLevelClass"/>
<module name="InterfaceIsType"/>
<module name="InnerTypeLast"/>
<module name="VisibilityModifier"/>
<module name="MutableException"/>
<module name="ThrowsCount"/>
<!-- Miscellaneous -->
<module name="ArrayTypeStyle"/>
<module name="UpperEll"/>
<module name="AvoidEscapedUnicodeCharacters"/>
<module name="DescendantToken"/>
<module name="FinalParameters"/>
<module name="Indentation"/>
<module name="OuterTypeFilename"/>
<module name="TodoComment"/>
<module name="TrailingComment"/>
<module name="UncommentedMain">
<property name="excludedClasses" value="\.Bootstrap"/>
</module>
<!-- Javadoc Comments -->
<module name="AtclauseOrder">
<property name="tagOrder" value="@author, @param, @return, @throws, @deprecated"/>
</module>
<module name="NonEmptyAtclauseDescription"/>
<module name="JavadocParagraph"/>
<module name="JavadocStyle"/>
<module name="JavadocTagContinuationIndentation"/>
<module name="SingleLineJavadoc"/>
<module name="SummaryJavadoc"/>
<module name="JavadocMethod">
<property name="scope" value="public"/>
<property name="allowedAnnotations" value="Override, Test, Before, After, BeforeClass, AfterClass, Parameterized, Parameters"/>
<property name="ignoreMethodNamesRegex" value="^assert.*$|^verify.*$"/>
<property name="tokens" value="METHOD_DEF, ANNOTATION_FIELD_DEF"/>
</module>
<!-- Filters -->
<module name="SuppressionCommentFilter"/>
<module name="SuppressWithNearbyCommentFilter"/>
</module>
</module>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册