-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removing dependency on checkstyle to remove guava for Android projects
- Loading branch information
Showing
13 changed files
with
594 additions
and
27 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
84 changes: 84 additions & 0 deletions
84
markdown/src/main/kotlin/com/appmattus/markdown/checkstyle/AuditEvent.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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// checkstyle: Checks Java source code for adherence to a set of rules. | ||
// Copyright (C) 2001-2019 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.appmattus.markdown.checkstyle | ||
|
||
/** | ||
* Raw event for audit. | ||
* | ||
* I'm not very satisfied about the design of this event since there are | ||
* optional methods that will return null in most of the case. This will | ||
* need some work to clean it up especially if we want to introduce | ||
* a more sequential reporting action rather than a packet error | ||
* reporting. This will allow for example to follow the process quickly | ||
* in an interface or a servlet (yep, that's cool to run a check via | ||
* a web interface in a source repository ;-) | ||
* | ||
* Creates a new `AuditEvent` instance. | ||
* | ||
* @param fileName file associated with the event | ||
* @param localizedMessage the actual message | ||
* @see AuditListener | ||
*/ | ||
class AuditEvent( | ||
val fileName: String, | ||
private val localizedMessage: LocalizedMessage? = null | ||
) { | ||
|
||
/** | ||
* Return the line number on the source file where the event occurred. | ||
* This may be 0 if there is no relation to a file content. | ||
* | ||
* @return an integer representing the line number in the file source code. | ||
*/ | ||
val line: Int | ||
get() = localizedMessage!!.lineNo | ||
|
||
/** | ||
* Return the message associated to the event. | ||
* | ||
* @return the event message | ||
*/ | ||
val message: String | ||
get() = localizedMessage!!.message | ||
|
||
/** | ||
* Gets the column associated with the message. | ||
* | ||
* @return the column associated with the message | ||
*/ | ||
val column: Int | ||
get() = localizedMessage!!.columnNo | ||
|
||
/** | ||
* Gets the audit event severity level. | ||
* | ||
* @return the audit event severity level | ||
*/ | ||
val severityLevel: SeverityLevel | ||
get() = localizedMessage?.severityLevel ?: SeverityLevel.INFO | ||
|
||
/** | ||
* Gets the name of the source for the message. | ||
* | ||
* @return the name of the source for the message | ||
*/ | ||
val sourceName: String | ||
get() = localizedMessage!!.sourceName | ||
} |
66 changes: 66 additions & 0 deletions
66
markdown/src/main/kotlin/com/appmattus/markdown/checkstyle/AuditListener.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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// checkstyle: Checks Java source code for adherence to a set of rules. | ||
// Copyright (C) 2001-2019 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.appmattus.markdown.checkstyle | ||
|
||
/** | ||
* Listener in charge of receiving events from the Checker. | ||
* Typical events sequence is: | ||
* | ||
* ``` | ||
* auditStarted | ||
* (fileStarted | ||
* (addError) | ||
* fileFinished) | ||
* auditFinished | ||
* ``` | ||
*/ | ||
interface AuditListener { | ||
|
||
/** | ||
* Notify that the audit is about to start. | ||
*/ | ||
fun auditStarted() | ||
|
||
/** | ||
* Notify that the audit is finished. | ||
*/ | ||
fun auditFinished() | ||
|
||
/** | ||
* Notify that audit is about to start on a specific file. | ||
* | ||
* @param event the event details | ||
*/ | ||
fun fileStarted(event: AuditEvent) | ||
|
||
/** | ||
* Notify that audit is finished on a specific file. | ||
* | ||
* @param event the event details | ||
*/ | ||
fun fileFinished(event: AuditEvent) | ||
|
||
/** | ||
* Notify that an audit error was discovered on a specific file. | ||
* | ||
* @param event the event details | ||
*/ | ||
fun addError(event: AuditEvent) | ||
} |
64 changes: 64 additions & 0 deletions
64
markdown/src/main/kotlin/com/appmattus/markdown/checkstyle/LocalizedMessage.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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// checkstyle: Checks Java source code for adherence to a set of rules. | ||
// Copyright (C) 2001-2019 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.appmattus.markdown.checkstyle | ||
|
||
/** | ||
* Represents a message that can be localised. The translations come from | ||
* message.properties files. The underlying implementation uses | ||
* java.text.MessageFormat. | ||
* | ||
* @param lineNo line number associated with the message | ||
* @param columnNo column number associated with the message | ||
* @param message the error message | ||
* @param severityLevel severity level for the message | ||
* @param sourceClass the Class that is the source of the message | ||
*/ | ||
data class LocalizedMessage( | ||
val lineNo: Int, | ||
val columnNo: Int, | ||
val message: String, | ||
val severityLevel: SeverityLevel, | ||
private val sourceClass: Class<*> | ||
) : Comparable<LocalizedMessage> { | ||
|
||
/** | ||
* Gets the name of the source for this LocalizedMessage. | ||
* | ||
* @return the name of the source for this LocalizedMessage | ||
*/ | ||
val sourceName: String = sourceClass.name | ||
|
||
//////////////////////////////////////////////////////////////////////////// | ||
// Interface Comparable methods | ||
//////////////////////////////////////////////////////////////////////////// | ||
|
||
@Suppress("ComplexMethod") | ||
override fun compareTo(other: LocalizedMessage): Int { | ||
return if (lineNo == other.lineNo) { | ||
if (columnNo == other.columnNo) { | ||
message.compareTo(other.message) | ||
} else { | ||
Integer.compare(columnNo, other.columnNo) | ||
} | ||
} else { | ||
Integer.compare(lineNo, other.lineNo) | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
markdown/src/main/kotlin/com/appmattus/markdown/checkstyle/OutputStreamOptions.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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.appmattus.markdown.checkstyle | ||
|
||
/** | ||
* Enum to specify behaviour regarding ignored modules. | ||
*/ | ||
enum class OutputStreamOptions { | ||
|
||
/** | ||
* Close stream in the end. | ||
*/ | ||
CLOSE, | ||
|
||
/** | ||
* Do nothing in the end. | ||
*/ | ||
NONE | ||
} |
61 changes: 61 additions & 0 deletions
61
markdown/src/main/kotlin/com/appmattus/markdown/checkstyle/SeverityLevel.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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// checkstyle: Checks Java source code for adherence to a set of rules. | ||
// Copyright (C) 2001-2019 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.appmattus.markdown.checkstyle | ||
|
||
import java.util.Locale | ||
|
||
/** | ||
* Severity level for a check violation. | ||
* | ||
* Each violation of an audit check is assigned one of the severity levels | ||
* defined here. | ||
* | ||
*/ | ||
enum class SeverityLevel { | ||
|
||
/** | ||
* Severity level ignore. | ||
*/ | ||
IGNORE, | ||
/** | ||
* Severity level info. | ||
*/ | ||
INFO, | ||
/** | ||
* Severity level warning. | ||
*/ | ||
WARNING, | ||
/** | ||
* Severity level error. | ||
*/ | ||
ERROR; | ||
|
||
/** | ||
* Returns name of severity level. | ||
* | ||
* @return the name of this severity level. | ||
*/ | ||
val value: String | ||
get() = name.toLowerCase(Locale.ENGLISH) | ||
|
||
override fun toString(): String { | ||
return value | ||
} | ||
} |
Oops, something went wrong.