-
Notifications
You must be signed in to change notification settings - Fork 7
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
Showing
16 changed files
with
3,191 additions
and
16 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
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
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
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
41 changes: 41 additions & 0 deletions
41
src/main/java/com/github/checkstyle/regression/data/ConfigNode.java
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,41 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// checkstyle: Checks Java source code for adherence to a set of rules. | ||
// Copyright (C) 2001-2017 the original author or authors. | ||
// | ||
// This library is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU Lesser General Public | ||
// License as published by the Free Software Foundation; either | ||
// version 2.1 of the License, or (at your option) any later version. | ||
// | ||
// This library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public | ||
// License along with this library; if not, write to the Free Software | ||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
package com.github.checkstyle.regression.data; | ||
|
||
import org.immutables.value.Value; | ||
|
||
/** | ||
* Represents a XML node in regression config. | ||
* @author LuoLiangchen | ||
*/ | ||
@Value.Immutable | ||
public interface ConfigNode { | ||
/** | ||
* The parent of this module. | ||
* @return the parent of this module | ||
*/ | ||
String parent(); | ||
|
||
/** | ||
* The module name. | ||
* @return the module name | ||
*/ | ||
String moduleName(); | ||
} |
58 changes: 58 additions & 0 deletions
58
src/main/java/com/github/checkstyle/regression/data/ModuleInfo.java
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,58 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// checkstyle: Checks Java source code for adherence to a set of rules. | ||
// Copyright (C) 2001-2017 the original author or authors. | ||
// | ||
// This library is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU Lesser General Public | ||
// License as published by the Free Software Foundation; either | ||
// version 2.1 of the License, or (at your option) any later version. | ||
// | ||
// This library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public | ||
// License along with this library; if not, write to the Free Software | ||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
package com.github.checkstyle.regression.data; | ||
|
||
import org.immutables.gson.Gson; | ||
import org.immutables.value.Value; | ||
|
||
/** | ||
* Represents the information of a checkstyle module. | ||
* @author LuoLiangchen | ||
*/ | ||
@Gson.TypeAdapters | ||
@Value.Immutable | ||
public abstract class ModuleInfo { | ||
/** | ||
* The package name of this module. | ||
* @return the package name of this module | ||
*/ | ||
public abstract String packageName(); | ||
|
||
/** | ||
* The name of this module. | ||
* @return the name of this module. | ||
*/ | ||
public abstract String name(); | ||
|
||
/** | ||
* The parent of this module. | ||
* The value should be either "TreeWalker" or "Checker". | ||
* @return the parent of this module. | ||
*/ | ||
public abstract String parent(); | ||
|
||
/** | ||
* Gets the full qualified name of this module. | ||
* @return the full qualified name of this module | ||
*/ | ||
public String getFullName() { | ||
return packageName() + "." + name(); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/main/java/com/github/checkstyle/regression/data/ModuleUpdate.java
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,59 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// checkstyle: Checks Java source code for adherence to a set of rules. | ||
// Copyright (C) 2001-2017 the original author or authors. | ||
// | ||
// This library is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU Lesser General Public | ||
// License as published by the Free Software Foundation; either | ||
// version 2.1 of the License, or (at your option) any later version. | ||
// | ||
// This library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public | ||
// License along with this library; if not, write to the Free Software | ||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
package com.github.checkstyle.regression.data; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.immutables.value.Value; | ||
|
||
/** | ||
* Represents the related changes of a checkstyle module. | ||
* Including the basic module information, change of the module class, change | ||
* of the corresponding test and changed of the utility classes that the module | ||
* depends on. | ||
* @author LuoLiangchen | ||
*/ | ||
@Value.Immutable | ||
public interface ModuleUpdate { | ||
/** | ||
* The basic information of the module. | ||
* @return the basic information of the module | ||
*/ | ||
ModuleInfo moduleInfo(); | ||
|
||
/** | ||
* The change of the module class. | ||
* @return the change of the module class | ||
*/ | ||
GitChange moduleChange(); | ||
|
||
/** | ||
* The change of the corresponding test class. | ||
* @return the change of the corresponding test class | ||
*/ | ||
Optional<GitChange> testChange(); | ||
|
||
/** | ||
* The changes of the utility classes that the module depends on. | ||
* @return the changes of the utility classes that the module depends on | ||
*/ | ||
List<GitChange> utilityChanges(); | ||
} |
69 changes: 69 additions & 0 deletions
69
src/main/java/com/github/checkstyle/regression/module/ModuleUpdateCollector.java
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,69 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// checkstyle: Checks Java source code for adherence to a set of rules. | ||
// Copyright (C) 2001-2017 the original author or authors. | ||
// | ||
// This library is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU Lesser General Public | ||
// License as published by the Free Software Foundation; either | ||
// version 2.1 of the License, or (at your option) any later version. | ||
// | ||
// This library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public | ||
// License along with this library; if not, write to the Free Software | ||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
package com.github.checkstyle.regression.module; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
import com.github.checkstyle.regression.data.GitChange; | ||
import com.github.checkstyle.regression.data.ImmutableModuleUpdate; | ||
import com.github.checkstyle.regression.data.ModuleUpdate; | ||
|
||
/** | ||
* Collects all the necessary information for the generation, in module level. | ||
* @author LuoLiangchen | ||
*/ | ||
public final class ModuleUpdateCollector { | ||
/** Prevents instantiation. */ | ||
private ModuleUpdateCollector() { | ||
} | ||
|
||
/** | ||
* Generates the module updates from a list of changes. | ||
* @param changes the changes source | ||
* @return the module updates generated from the given changes | ||
*/ | ||
public static List<ModuleUpdate> generateModuleUpdates(List<GitChange> changes) { | ||
final Map<String, ModuleUpdate> moduleUpdates = changes.stream() | ||
.filter(ModuleUtils::isCheckstyleModule) | ||
.map(change -> { | ||
return ImmutableModuleUpdate.builder() | ||
.moduleChange(change) | ||
.moduleInfo(ModuleUtils.convertModuleChangeToModuleInfo(change)) | ||
.build(); | ||
}) | ||
.collect(Collectors.toMap( | ||
update -> update.moduleInfo().getFullName(), update -> update)); | ||
for (GitChange change : changes) { | ||
if (ModuleUtils.isCheckstyleModuleTest(change)) { | ||
final String fullName = ModuleUtils.convertModuleTestChangeToModuleFullName(change); | ||
if (moduleUpdates.containsKey(fullName)) { | ||
final ModuleUpdate update = ImmutableModuleUpdate | ||
.copyOf(moduleUpdates.get(fullName)) | ||
.withTestChange(change); | ||
moduleUpdates.put(fullName, update); | ||
} | ||
} | ||
} | ||
|
||
return moduleUpdates.values().stream().collect(Collectors.toList()); | ||
} | ||
} |
Oops, something went wrong.