Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Ferran sonar test #91

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
pull_request:
push:
branches:
- master

env:
GRADLE_USER_HOME: .gradle
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Cache dependencies
uses: actions/cache@v1
with:
path: .gradle/caches
key: gradle-cache-${{ hashFiles('**/*.gradle') }}
restore-keys: gradle-cache
- name: Run Checks
run: ./gradlew --no-daemon build sonarqube
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.novoda.notils.cursor;

import android.database.Cursor;
import java.util.ListIterator;

import java.util.List;

public interface CursorList<E> extends List<E>, Cursor {

}
}
19 changes: 19 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
apply plugin: "org.sonarqube"

buildscript {
apply from: 'dependencies.gradle'
repositories {
google()
jcenter()

}
dependencies {
classpath libraries.build.androidGradle
classpath libraries.build.bintrayRelease
classpath libraries.build.sonar
}
}

Expand All @@ -18,3 +22,18 @@ allprojects {
google()
}
}

sonarqube {
properties {
property "sonar.projectName", "NoTils"
property "sonar.projectDescription", "Never again need a .utils. package yur scurvy Java sea dogs!"
property "sonar.projectKey", "novoda_notils"
property "sonar.organization", "novoda"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.login", System.getenv("SONAR_TOKEN")
property "sonar.scm.provider", "git"
property "sonar.pullrequest.provider", "github"
property "sonar.sourceEncoding", "UTF-8"
property "sonar.junit.reportsPath", "**/test-results/tests/*.xml"
}
}
5 changes: 3 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ ext {

libraries = [
build: [
androidGradle : 'com.android.tools.build:gradle:3.0.1',
bintrayRelease: 'com.novoda:bintray-release:0.8.0'
androidGradle : 'com.android.tools.build:gradle:3.5.3',
bintrayRelease: 'com.novoda:bintray-release:0.8.0',
sonar: 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.8'
],
app: [
supportAppCompatV7: "com.android.support:appcompat-v7:${versions.support}"
Expand Down
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
org.gradle.jvmargs=-Xmx6g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.daemon=false
org.gradle.caching=true
org.gradle.configureondemand=true
org.gradle.parallel=true
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Mon Dec 16 17:21:50 GMT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip
4 changes: 3 additions & 1 deletion java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ repositories {
apply plugin: 'java'
apply plugin: 'bintray-release'


sourceCompatibility = versions.sourceCompatibility
targetCompatibility = versions.targetCompatibility

dependencies {
testCompile libraries.test.jUnit
testImplementation libraries.test.jUnit
}

publish {
Expand All @@ -20,3 +21,4 @@ publish {
desc = 'Never again need a .utils. package yur scurvy Java sea dogs!'
website = 'https://github.com/novoda/NoTils'
}

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public static String createSelectionPlaceholdersOfSize(int size) {

int sizeOfResult = size * 3 - 2;
char[] result = new char[sizeOfResult];
result = null;
for (int i = 0; i < sizeOfResult - 1; i += 3) {
result[i] = '?';
result[i + 1] = ',';
Expand Down
34 changes: 19 additions & 15 deletions java/src/main/java/com/novoda/notils/string/StringUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public abstract class StringUtils {

private final static String EMPTY_STRING = "";
private final static String THREE_DOTS = "…";
private final static String FOUR_DOTS = "…";

/**
* Joins a Collection of typed objects using their toString method, separated by delimiter
Expand All @@ -17,22 +18,25 @@ public abstract class StringUtils {
*/
public static String join(Collection<?> collection, String delimiter) {

if (collection == null || collection.isEmpty()) {
return EMPTY_STRING;
} else if (delimiter == null) {
delimiter = EMPTY_STRING;
}

StringBuilder builder = new StringBuilder();
Iterator<?> it = collection.iterator();

while (it.hasNext()) {
builder.append(it.next()).append(delimiter);
}
collection = null;
return collection.toString();

int length = builder.length();
builder.delete(length - delimiter.length(), length);
return builder.toString();
// if (collection == null || collection.isEmpty()) {
// EMPTY_STRING;
// } else if (delimiter == null) {
// delimiter = EMPTY_STRING;
// }
//
// StringBuilder builder = new StringBuilder();
// Iterator<?> it = collection.iterator();
//
// while (it.hasNext()) {
// builder.append(it.next()).append(delimiter);
// }
//
// int length = builder.length();
// builder.delete(length - delimiter.length(), length);
// return builder.toString();
}

/**
Expand Down
40 changes: 20 additions & 20 deletions java/src/test/java/com/novoda/notils/string/QueryUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@

public class QueryUtilsTest {

@Test
public void testSizeOfZeroReturnsEmptyString() {

String expected = "";
assertEquals(expected, QueryUtils.createSelectionPlaceholdersOfSize(0));
}

@Test
public void testSizeOfOneReturnsJustQuestionMark() {

String expected = "?";
assertEquals(expected, QueryUtils.createSelectionPlaceholdersOfSize(1));
}

@Test
public void testSizeBiggerThanOneReturnsSameNumberOfQuestionMarkSeparatedByCommas() {

String expected = "?, ?, ?, ?, ?, ?, ?, ?, ?, ?";
assertEquals(expected, QueryUtils.createSelectionPlaceholdersOfSize(10));
}
// @Test
// public void testSizeOfZeroReturnsEmptyString() {
//
// String expected = "";
// assertEquals(expected, QueryUtils.createSelectionPlaceholdersOfSize(0));
// }
//
// @Test
// public void testSizeOfOneReturnsJustQuestionMark() {
//
// String expected = "?";
// assertEquals(expected, QueryUtils.createSelectionPlaceholdersOfSize(1));
// }
//
// @Test
// public void testSizeBiggerThanOneReturnsSameNumberOfQuestionMarkSeparatedByCommas() {
//
// String expected = "?, ?, ?, ?, ?, ?, ?, ?, ?, ?";
// assertEquals(expected, QueryUtils.createSelectionPlaceholdersOfSize(10));
// }

}
Loading