forked from adrienmo/sonar-elixir
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix sensor and update tests. Add coverage report.
- Loading branch information
Showing
12 changed files
with
282 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,6 @@ jdk: | |
- oraclejdk7 | ||
- oraclejdk8 | ||
|
||
after_success: | ||
- mvn clean test jacoco:report coveralls:report | ||
|
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
SonarQube Elixir Plugin | ||
=========== | ||
[![build status](https://travis-ci.org/arthepsy/sonar-elixir.svg?branch=master)](https://travis-ci.org/arthepsy/sonar-elixir/) | ||
[![Coverage Status](https://coveralls.io/repos/arthepsy/sonar-elixir/badge.svg?branch=master)](https://coveralls.io/r/arthepsy/sonar-elixir?branch=master) | ||
|
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
42 changes: 42 additions & 0 deletions
42
...elixir-plugin/src/test/java/eu/arthepsy/sonar/plugins/elixir/ElixirConfigurationTest.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,42 @@ | ||
/* | ||
* SonarQube Elixir plugin | ||
* Copyright (C) 2015 Andris Raugulis | ||
* [email protected] | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package eu.arthepsy.sonar.plugins.elixir; | ||
|
||
import eu.arthepsy.sonar.plugins.elixir.util.ClassDefinition; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.fest.assertions.Assertions.assertThat; | ||
|
||
public class ElixirConfigurationTest { | ||
@Test | ||
public void testClassDefinition() { | ||
ClassDefinition.testFinalClassDefinition(ElixirConfiguration.class); | ||
} | ||
|
||
@Test | ||
public void testPropertyCount() { | ||
assertThat(ElixirConfiguration.getPropertyDefinitions().size()).isEqualTo(0); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
sonar-elixir-plugin/src/test/java/eu/arthepsy/sonar/plugins/elixir/ElixirPluginTest.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,35 @@ | ||
/* | ||
* SonarQube Elixir plugin | ||
* Copyright (C) 2015 Andris Raugulis | ||
* [email protected] | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package eu.arthepsy.sonar.plugins.elixir; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.fest.assertions.Assertions.assertThat; | ||
|
||
public class ElixirPluginTest { | ||
@Test | ||
public void testExtensionCount() { | ||
assertThat(new ElixirPlugin().getExtensions().size()).isEqualTo(3); | ||
} | ||
} |
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
38 changes: 38 additions & 0 deletions
38
sonar-elixir-plugin/src/test/java/eu/arthepsy/sonar/plugins/elixir/language/ElixirTest.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,38 @@ | ||
/* | ||
* SonarQube Elixir plugin | ||
* Copyright (C) 2015 Andris Raugulis | ||
* [email protected] | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package eu.arthepsy.sonar.plugins.elixir.language; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.fest.assertions.Assertions.assertThat; | ||
|
||
public class ElixirTest { | ||
@Test | ||
public void test() { | ||
Elixir language = new Elixir(); | ||
assertThat(language.getKey()).isEqualTo("elixir"); | ||
assertThat(language.getName()).isEqualTo("Elixir"); | ||
assertThat(language.getFileSuffixes()).containsOnly("ex", "exs"); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...-plugin/src/test/java/eu/arthepsy/sonar/plugins/elixir/rule/ElixirQualityProfileTest.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,49 @@ | ||
/* | ||
* SonarQube Elixir plugin | ||
* Copyright (C) 2015 Andris Raugulis | ||
* [email protected] | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package eu.arthepsy.sonar.plugins.elixir.rule; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.mockito.Mockito; | ||
import org.sonar.api.profiles.RulesProfile; | ||
import org.sonar.api.utils.ValidationMessages; | ||
|
||
import static org.fest.assertions.Assertions.assertThat; | ||
|
||
public class ElixirQualityProfileTest { | ||
private ElixirQualityProfile profile; | ||
private ValidationMessages validationMessages; | ||
|
||
@Before | ||
public void prepare() { | ||
profile = Mockito.spy(new ElixirQualityProfile()); | ||
validationMessages = ValidationMessages.create(); | ||
} | ||
|
||
@Test | ||
public void testRulesCount() { | ||
RulesProfile rulesProfile = profile.createProfile(validationMessages); | ||
assertThat(rulesProfile.getActiveRules().size()).isEqualTo(0); | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
sonar-elixir-plugin/src/test/java/eu/arthepsy/sonar/plugins/elixir/util/ClassDefinition.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,74 @@ | ||
/* | ||
* SonarQube Elixir plugin | ||
* Copyright (C) 2015 Andris Raugulis | ||
* [email protected] | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package eu.arthepsy.sonar.plugins.elixir.util; | ||
|
||
import static org.junit.Assert.fail; | ||
|
||
import java.lang.reflect.Constructor; | ||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
import java.lang.reflect.Modifier; | ||
|
||
import static org.fest.assertions.Assertions.assertThat; | ||
|
||
public final class ClassDefinition { | ||
|
||
public static void testFinalClassDefinition(Class<?> clazz) { | ||
testFinalClassDefinition(clazz, false); | ||
} | ||
|
||
public static void testFinalClassDefinition(Class<?> clazz, Boolean privateConstructor) { | ||
assertThat(Modifier.isFinal(clazz.getModifiers())).isTrue(); | ||
final Constructor<?> constructor; | ||
try { | ||
constructor = clazz.getDeclaredConstructor(); | ||
} catch (NoSuchMethodException e) { | ||
fail(e.getMessage()); | ||
return; | ||
} | ||
if (privateConstructor) { | ||
assertThat(Modifier.isPrivate(constructor.getModifiers())).isTrue(); | ||
} | ||
constructor.setAccessible(true); | ||
try { | ||
constructor.newInstance(); | ||
} catch (InstantiationException e) { | ||
fail(e.getMessage()); | ||
return; | ||
} catch (IllegalAccessException e) { | ||
fail(e.getMessage()); | ||
return; | ||
} catch (InvocationTargetException e) { | ||
fail(e.getMessage()); | ||
return; | ||
} | ||
constructor.setAccessible(false); | ||
for (final Method method: clazz.getMethods()) { | ||
if (method.getDeclaringClass().equals(clazz)) { | ||
assertThat(Modifier.isStatic(method.getModifiers())).isTrue(); | ||
} | ||
} | ||
} | ||
|
||
} |
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