diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f1ac78e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,37 @@ +name: SonarCloud +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] +jobs: + build: + name: Build and analyze + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Cache SonarCloud packages + uses: actions/cache@v1 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Cache Gradle packages + uses: actions/cache@v1 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: ${{ runner.os }}-gradle + - name: Build and analyze + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: ./gradlew build sonarqube --info + diff --git a/build.gradle b/build.gradle index 10c88ad..8e45d37 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,15 @@ plugins { id "java-library" id "com.github.johnrengelman.shadow" version "2.0.3" apply false + id "org.sonarqube" version "3.5.0.2730" +} + +sonarqube { + properties { + property "sonar.projectKey", "viveknittmca_java-timeseries" + property "sonar.organization", "viveknittmca" + property "sonar.host.url", "https://sonarcloud.io" + } } compileJava { diff --git a/timeseries/src/main/java/com/github/signaflo/data/visualization/Plots.java b/timeseries/src/main/java/com/github/signaflo/data/visualization/Plots.java index c9209ce..0ab159a 100644 --- a/timeseries/src/main/java/com/github/signaflo/data/visualization/Plots.java +++ b/timeseries/src/main/java/com/github/signaflo/data/visualization/Plots.java @@ -99,8 +99,9 @@ public static void plot(final TimeSeries timeSeries, final String title, final S residualSeries.setXYSeriesRenderStyle(XYSeries.XYSeriesRenderStyle.Scatter); residualSeries.setMarker(new Circle()).setMarkerColor(Color.RED); - JPanel panel = new XChartPanel<>(chart); JFrame frame = new JFrame(title); + JPanel panel = new XChartPanel<>(chart); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.add(panel); frame.pack(); @@ -116,8 +117,9 @@ public static void plot(final TimeSeries timeSeries, final String title, final S * @param k the maximum lag to include in the acf plot. */ public static void plotAcf(TimeSeries timeSeries, final int k) { - final double[] acf = timeSeries.autoCorrelationUpToLag(k); final double[] lags = new double[k + 1]; + final double[] acf = timeSeries.autoCorrelationUpToLag(k); + for (int i = 1; i < lags.length; i++) { lags[i] = i; }