Add codenarc support for making sure the code continues to look nice

This commit is contained in:
R. Tyler Croy 2015-04-23 11:42:47 -07:00
parent e58a00d001
commit c30c2ae2f2
5 changed files with 36 additions and 2 deletions

View File

@ -12,6 +12,7 @@ buildscript {
}
}
apply plugin: 'codenarc'
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'idea'
@ -75,6 +76,12 @@ test {
/* Whenever we're building an artifact, we should run the tests */
assemble.dependsOn check
jar.dependsOn check
codenarc {
sourceSets = [sourceSets.main]
configFile = file('gradle/codenarc.xml')
}
assemble.dependsOn codenarcMain
////////

23
gradle/codenarc.xml Normal file
View File

@ -0,0 +1,23 @@
<ruleset xmlns="http://codenarc.org/ruleset/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://codenarc.org/ruleset/1.0 http://codenarc.org/ruleset-schema.xsd"
xsi:noNamespaceSchemaLocation="http://codenarc.org/ruleset-schema.xsd">
<description>Sample rule set</description>
<ruleset-ref path='rulesets/imports.xml'>
<rule-config name='DuplicateImport'>
<property name='priority' value='1'/>
</rule-config>
</ruleset-ref>
<ruleset-ref path='rulesets/basic.xml'>
<exclude name='StringInstantiation'/>
</ruleset-ref>
<rule class='org.codenarc.rule.generic.IllegalRegexRule'>
<property name="name" value="AuthorTagNotAllowed"/>
<property name='regex' value='\@author'/>
</rule>
</ruleset>

View File

@ -1,10 +1,8 @@
package com.github.lookout.serviceartifact
import com.github.jrubygradle.jar.JRubyJarConfigurator
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.tasks.bundling.Jar
import org.slf4j.Logger
import org.slf4j.LoggerFactory

View File

@ -2,11 +2,16 @@ package com.github.lookout.serviceartifact.scm
import groovy.transform.TypeChecked
import org.slf4j.Logger
import org.slf4j.LoggerFactory
@TypeChecked
abstract class AbstractScmHandler {
/** Supplied environment variables */
protected Map<String, String> env
protected Logger logger = LoggerFactory.getLogger(this.class)
/** Return true if the runtime environment has the necessary information to
* make this SCM Handler available for use
*/

View File

@ -46,6 +46,7 @@ class GitHandler extends AbstractScmHandler {
this._git = Grgit.open('.')
}
catch (RepositoryNotFoundException ex) {
this.logger.debug("Repository not found", ex)
}
}