Skip to content

Commit

Permalink
Fix codenarc rule: formatting (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
zpencer authored Jul 26, 2017
1 parent 8fac7ab commit 54ee5db
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 24 deletions.
6 changes: 1 addition & 5 deletions config/codenarc/codenarc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<exclude name="ImplementationAsType"/>
</ruleset-ref>
<ruleset-ref path='rulesets/exceptions.xml'/>
<ruleset-ref path='rulesets/formatting.xml'/>
<ruleset-ref path='rulesets/generic.xml'/>
<ruleset-ref path='rulesets/grails.xml'/>
<ruleset-ref path='rulesets/groovyism.xml'/>
Expand All @@ -61,11 +62,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<ruleset-ref path='rulesets/unused.xml'/>
<!-- The following rules do not pass yet
<ruleset-ref path='rulesets/dry.xml'/>
<ruleset-ref path='rulesets/formatting.xml'>
<rule-config name="LineLength">
<property name='length' value='100'/>
</rule-config>
</ruleset-ref>
<ruleset-ref path='rulesets/naming.xml'/>
<ruleset-ref path='rulesets/unnecessary.xml'/>
-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package com.google.protobuf.gradle

import org.gradle.api.Named
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ public class GenerateProtoTask extends DefaultTask {

private State state = State.INIT


private void checkInitializing() {
Preconditions.checkState(state == State.INIT, 'Should not be called after initilization has finished')
}
Expand Down Expand Up @@ -370,7 +369,7 @@ public class GenerateProtoTask extends DefaultTask {
outputDir.mkdirs()
}

List<String> dirs = includeDirs*.path.collect {"-I${it}"}
List<String> dirs = includeDirs*.path.collect { "-I${it}" }
logger.debug "ProtobufCompile using directories ${dirs}"
logger.debug "ProtobufCompile using files ${protoFiles}"
List<String> cmd = [ tools.protoc.path ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package com.google.protobuf.gradle

import org.gradle.api.Project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package com.google.protobuf.gradle

import org.gradle.api.Project
Expand Down
10 changes: 6 additions & 4 deletions src/main/groovy/com/google/protobuf/gradle/ProtobufPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package com.google.protobuf.gradle

import com.google.common.collect.ImmutableList
Expand All @@ -46,6 +45,9 @@ import org.gradle.api.tasks.SourceSet

import javax.inject.Inject

/**
* The main class for the protobuf plugin.
*/
class ProtobufPlugin implements Plugin<Project> {
// any one of these plugins should be sufficient to proceed with applying this plugin
private static final List<String> prerequisitePluginOptions = [
Expand Down Expand Up @@ -98,7 +100,7 @@ class ProtobufPlugin implements Plugin<Project> {

private void doApply() {
// Provides the osdetector extension
project.apply plugin: 'com.google.osdetector'
project.apply([plugin:'com.google.osdetector'])

project.convention.plugins.protobuf = new ProtobufConvention(project, fileResolver);

Expand Down Expand Up @@ -190,7 +192,7 @@ class ProtobufPlugin implements Plugin<Project> {
generateProtoTask.sourceSet = sourceSet
generateProtoTask.doneInitializing()
generateProtoTask.builtins {
java {}
java { }
}

Task extractProtosTask = maybeAddExtractProtosTask(sourceSet.name)
Expand Down Expand Up @@ -398,7 +400,7 @@ class ProtobufPlugin implements Plugin<Project> {
project.protobuf.generateProtoTasks.ofSourceSet(sourceSet.name).each { generateProtoTask ->
javaCompileTask.dependsOn(generateProtoTask)
generateProtoTask.getAllOutputDirs().each { dir ->
javaCompileTask.source project.fileTree(dir: dir)
javaCompileTask.source project.fileTree([dir:dir])
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package com.google.protobuf.gradle

import org.gradle.api.internal.file.DefaultSourceDirectorySet
Expand Down
11 changes: 5 additions & 6 deletions src/main/groovy/com/google/protobuf/gradle/ToolsLocator.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package com.google.protobuf.gradle

import org.gradle.api.GradleException
Expand Down Expand Up @@ -82,11 +81,11 @@ class ToolsLocator {
String groupId, artifact, version
(groupId, artifact, version) = locator.artifact.split(":")
Map<String, String> notation = [
group: groupId,
name: artifact,
version: version,
classifier: project.osdetector.classifier,
ext: 'exe',
group:groupId,
name:artifact,
version:version,
classifier:project.osdetector.classifier,
ext:'exe',
]
Dependency dep = project.dependencies.add(config.name, notation)

Expand Down
4 changes: 3 additions & 1 deletion src/main/groovy/com/google/protobuf/gradle/Utils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package com.google.protobuf.gradle

import org.apache.commons.lang.StringUtils
Expand All @@ -37,6 +36,9 @@ import org.gradle.api.tasks.TaskInputs

import java.util.regex.Matcher

/**
* Utility classes.
*/
class Utils {
/**
* Returns the conventional name of a configuration for a sourceSet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.TaskOutcome
import spock.lang.Specification

/**
* Unit tests for android related functionality.
*/
class ProtobufAndroidPluginTest extends Specification {

void "testProjectAndroid should be successfully executed"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.TaskOutcome
import spock.lang.Specification

/**
* Unit tests for normal java functionality.
*/
class ProtobufJavaPluginTest extends Specification {
private static final List<String> gradleVersions = ["2.12", "3.0", "4.0"]

private Project setupBasicProject() {
Project project = ProjectBuilder.builder().build()
project.apply plugin: 'java'
project.apply plugin: 'com.google.protobuf'
project.apply plugin:'java'
project.apply plugin:'com.google.protobuf'
return project
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import org.apache.commons.io.FileUtils

/**
* Utility class.
*/
class ProtobufPluginTestHelper {

static void appendPluginClasspath(File buildFile) {
Expand Down

0 comments on commit 54ee5db

Please sign in to comment.