-
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,165 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
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
58 changes: 58 additions & 0 deletions
58
src/main/java/com/github/checkstyle/regression/data/ModuleExtractInfo.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 extract information of a checkstyle module. | ||
* @author LuoLiangchen | ||
*/ | ||
@Gson.TypeAdapters | ||
@Value.Immutable | ||
public abstract class ModuleExtractInfo { | ||
/** | ||
* 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(); | ||
|
||
/** | ||
* The full qualified name of this module. | ||
* @return the full qualified name of this module | ||
*/ | ||
public String fullName() { | ||
return packageName() + "." + name(); | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
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,73 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// 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 org.immutables.value.Value; | ||
|
||
/** | ||
* Represents the related information of a checkstyle module. | ||
* Including the extract 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 | ||
@Value.Modifiable | ||
public abstract class ModuleInfo { | ||
/** | ||
* The basic information of the module. | ||
* @return the basic information of the module | ||
*/ | ||
public abstract ModuleExtractInfo moduleExtractInfo(); | ||
|
||
/** | ||
* The properties of the module. | ||
* @return the properties of the module | ||
*/ | ||
public abstract List<Property> properties(); | ||
|
||
/** | ||
* The name of the module. | ||
* @return the name of the module | ||
*/ | ||
public String name() { | ||
return moduleExtractInfo().name(); | ||
} | ||
|
||
/** | ||
* Represents the property and its settings of a module. | ||
*/ | ||
@Value.Immutable | ||
public interface Property { | ||
/** | ||
* The name of the property. | ||
* @return the name of the property | ||
*/ | ||
String name(); | ||
|
||
/** | ||
* The value of the property. | ||
* @return the value of the property | ||
*/ | ||
String value(); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
src/main/java/com/github/checkstyle/regression/module/ModuleCollector.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,62 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// 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.LinkedHashMap; | ||
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.ModifiableModuleInfo; | ||
import com.github.checkstyle.regression.data.ModuleExtractInfo; | ||
import com.github.checkstyle.regression.data.ModuleInfo; | ||
|
||
/** | ||
* Collects all the necessary information for the generation, in module level. | ||
* @author LuoLiangchen | ||
*/ | ||
public final class ModuleCollector { | ||
/** Prevents instantiation. */ | ||
private ModuleCollector() { | ||
} | ||
|
||
/** | ||
* 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<ModuleInfo> generate(List<GitChange> changes) { | ||
final Map<String, ModifiableModuleInfo> moduleInfos = new LinkedHashMap<>(); | ||
for (GitChange change : changes) { | ||
if (ModuleUtils.isCheckstyleModule(change)) { | ||
final ModuleExtractInfo extractInfo = | ||
ModuleUtils.convertModuleChangeToExtractInfo(change); | ||
final ModifiableModuleInfo moduleInfo = ModifiableModuleInfo.create() | ||
.setModuleExtractInfo(extractInfo); | ||
moduleInfos.put(extractInfo.fullName(), moduleInfo); | ||
} | ||
} | ||
|
||
return moduleInfos.values().stream() | ||
.map(ModifiableModuleInfo::toImmutable) | ||
.collect(Collectors.toList()); | ||
} | ||
} |
Oops, something went wrong.