UT coverage for AvoidStarImportCheck. #1128

This commit is contained in:
Aleksandr Ivanov 2015-06-15 21:58:25 +03:00 committed by Roman Ivanov
parent 44b3fe0b14
commit d938bf243b
2 changed files with 3 additions and 12 deletions

View File

@ -813,8 +813,6 @@
<regex><pattern>.*.checks.header.RegexpHeaderCheck</pattern><branchRate>87</branchRate><lineRate>93</lineRate></regex>
<regex><pattern>.*.checks.imports.AvoidStarImportCheck</pattern><branchRate>95</branchRate><lineRate>100</lineRate></regex>
<regex><pattern>.*.checks.imports.AvoidStaticImportCheck</pattern><branchRate>91</branchRate><lineRate>100</lineRate></regex>
<regex><pattern>.*.checks.imports.CustomImportOrderCheck</pattern><branchRate>93</branchRate><lineRate>91</lineRate></regex>
<regex><pattern>.*.checks.imports.Guard</pattern><branchRate>86</branchRate><lineRate>100</lineRate></regex>
<regex><pattern>.*.checks.imports.ImportControlCheck</pattern><branchRate>85</branchRate><lineRate>73</lineRate></regex>

View File

@ -154,17 +154,10 @@ public class AvoidStarImportCheck
*/
private void logsStarredImportViolation(DetailAST startingDot) {
final FullIdent name = FullIdent.createFullIdent(startingDot);
if (isStaredImport(name) && !excludes.contains(name.getText())) {
log(startingDot.getLineNo(), MSG_KEY, name.getText());
final String importText = name.getText();
if (importText.endsWith(".*") && !excludes.contains(importText)) {
log(startingDot.getLineNo(), MSG_KEY, importText);
}
}
/**
* Checks is an import is a stared import.
* @param importIdent the full import identifier
* @return true if a start import false if not
*/
private boolean isStaredImport(FullIdent importIdent) {
return null != importIdent && importIdent.getText().endsWith(".*");
}
}