Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use SQ API 6.7 #1291

Merged
merged 10 commits into from
Nov 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
target
.project
.classpath
.idea/
.idea/
.pydevproject
*.iml
*.prefs
.sonar
Expand Down
26 changes: 1 addition & 25 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,7 @@ jdk:
- oraclejdk8

env:
- SONARHOME=/tmp/sonarqube-5.6.7 SONARAPI=SqApi56
- SONARHOME=/tmp/sonarqube-6.0 SONARAPI=SqApi56
- SONARHOME=/tmp/sonarqube-6.1 SONARAPI=SqApi56
- SONARHOME=/tmp/sonarqube-6.2 SONARAPI=SqApi62
- SONARHOME=/tmp/sonarqube-6.3.1 SONARAPI=SqApi62
- SONARHOME=/tmp/sonarqube-6.4 SONARAPI=SqApi62
- SONARHOME=/tmp/sonarqube-6.5 SONARAPI=SqApi62
- SONARHOME=/tmp/sonarqube-6.6 SONARAPI=SqApi62
- SONARHOME=/tmp/sonarqube-6.7 SONARAPI=SqApi62
- SONARHOME=/tmp/sonarqube-6.7 SONARAPI=SqApi67

matrix:
fast_finish: true
Expand Down Expand Up @@ -46,22 +38,6 @@ before_install:

install:
- cd /tmp
- travis_retry wget -q https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-5.6.7.zip
- unzip -qq sonarqube-5.6.7.zip
- travis_retry wget -q https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-6.0.zip
- unzip -qq sonarqube-6.0.zip
- travis_retry wget -q https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-6.1.zip
- unzip -qq sonarqube-6.1.zip
- travis_retry wget -q https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-6.2.zip
- unzip -qq sonarqube-6.2.zip
- travis_retry wget -q https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-6.3.1.zip
- unzip -qq sonarqube-6.3.1.zip
- travis_retry wget -q https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-6.4.zip
- unzip -qq sonarqube-6.4.zip
- travis_retry wget -q https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-6.5.zip
- unzip -qq sonarqube-6.5.zip
- travis_retry wget -q https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-6.6.zip
- unzip -qq sonarqube-6.6.zip
- travis_retry wget -q https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-6.7.zip
- unzip -qq sonarqube-6.7.zip
- travis_retry wget -q https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.0.3.778.zip
Expand Down
12 changes: 6 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ install:
}
if (!(Test-Path -Path "C:\sonarqube" )) {
(new-object System.Net.WebClient).DownloadFile(
'https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-5.6.7.zip',
'C:\sonarqube-5.6.7.zip'
'https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-6.7.zip',
'C:\sonarqube-6.7.zip'
)
[System.IO.Compression.ZipFile]::ExtractToDirectory("C:\sonarqube-5.6.7.zip", "C:\sonarqube")
[System.IO.Compression.ZipFile]::ExtractToDirectory("C:\sonarqube-6.7.zip", "C:\sonarqube")
}
- ps: |
If ($env:Platform -Match "x86") {
Expand All @@ -49,7 +49,7 @@ install:
- cmd: SET PATH=C:\maven\apache-maven-3.2.5\bin;%JAVA_HOME%\bin;C:\sonar-scanner\sonar-scanner-3.0.3.778\bin;%PATH%
- cmd: SET M2_HOME=C:\maven\apache-maven-3.2.5
- cmd: SET MAVEN_HOME=C:\maven\apache-maven-3.2.5
- cmd: SET SONARHOME=C:\sonarqube\sonarqube-5.6.7
- cmd: SET SONARHOME=C:\sonarqube\sonarqube-6.7
- cmd: SET TestDataFolder=C:\projects\sonar-cxx\integration-tests\testdata
- cmd: SET

Expand All @@ -68,7 +68,7 @@ build_script:
- C:\Python27\Scripts\pip.exe install colorama
- mvn org.jacoco:jacoco-maven-plugin:prepare-agent clean install -Pcoverage-per-test
- IF "%APPVEYOR_PULL_REQUEST_NUMBER%"=="" (mvn sonar:sonar -Dsonar.organization=sonaropencommunity -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=%sonarcloudtoken%) ELSE (ECHO SKIP ANALYSIS)
- C:\Python27\Scripts\behave.exe --no-capture --tags=SqApi56
- C:\Python27\Scripts\behave.exe --no-capture --tags=SqApi67
cache:
- C:\Users\appveyor\.m2
artifacts:
Expand All @@ -80,4 +80,4 @@ on_failure:
- ps: Get-ChildItem cxx-checks\target\surefire-reports\*.txt | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
- ps: Get-ChildItem sonar-cxx-plugin\target\surefire-reports\*.txt | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
- ps: Get-ChildItem *.log | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
- ps: Get-ChildItem C:\sonarqube\sonarqube-5.6.7\logs\* | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
- ps: Get-ChildItem C:\sonarqube\sonarqube-6.7\logs\* | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
6 changes: 3 additions & 3 deletions cxx-checks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert</artifactId>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*/
package org.sonar.cxx.checks;

import java.util.List;

import org.sonar.check.Priority;
import org.sonar.check.Rule;
import org.sonar.check.RuleProperty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.file.Files;
import java.nio.charset.Charset;
import java.util.Optional;

import org.mockito.Mockito;
import static org.mockito.Mockito.when;
import org.sonar.api.batch.fs.internal.DefaultInputFile;

import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
import org.sonar.api.batch.sensor.internal.SensorContextTester;
import org.sonar.cxx.CxxLanguage;

Expand All @@ -39,19 +42,17 @@ public static CxxFileTester CreateCxxFileTester(String fileName, String basePath
CxxFileTester tester = new CxxFileTester();
tester.sensorContext = SensorContextTester.create(new File(basePath));

String content = new String(Files.readAllBytes(new File(tester.sensorContext.fileSystem().baseDir(), fileName).toPath()), "UTF-8");
tester.sensorContext.fileSystem().add(new DefaultInputFile("myProjectKey", fileName).initMetadata(content));
tester.sensorContext.fileSystem().add(TestInputFileBuilder.create("", fileName).build());
tester.cxxFile = tester.sensorContext.fileSystem().inputFile(tester.sensorContext.fileSystem().predicates().hasPath(fileName));

return tester;
}
public static CxxFileTester CreateCxxFileTester(String fileName, String basePath, String encoding) throws UnsupportedEncodingException, IOException {

public static CxxFileTester CreateCxxFileTester(String fileName, String basePath,Charset charset) throws UnsupportedEncodingException, IOException {
CxxFileTester tester = new CxxFileTester();
tester.sensorContext = SensorContextTester.create(new File(basePath));

String content = new String(Files.readAllBytes(new File(tester.sensorContext.fileSystem().baseDir(), fileName).toPath()), encoding);
tester.sensorContext.fileSystem().add(new DefaultInputFile("myProjectKey", fileName).initMetadata(content));
tester.sensorContext.fileSystem().add(TestInputFileBuilder.create("", fileName).setCharset(charset).build());
tester.cxxFile = tester.sensorContext.fileSystem().inputFile(tester.sensorContext.fileSystem().predicates().hasPath(fileName));

return tester;
Expand All @@ -62,7 +63,7 @@ public static CxxLanguage mockCxxLanguage() {
when(language.getKey()).thenReturn("c++");
when(language.getName()).thenReturn("c++");
when(language.getPropertiesKey()).thenReturn("cxx");
when(language.IsRecoveryEnabled()).thenReturn(true);
when(language.IsRecoveryEnabled()).thenReturn(Optional.of(Boolean.TRUE));
when(language.getFileSuffixes())
.thenReturn(new String [] { ".cpp", ".hpp", ".h", ".cxx", ".c", ".cc", ".hxx", ".hh" });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class FileEncodingCheckTest {
public void testAsciiFileAsciiEncoding() throws UnsupportedEncodingException, IOException {
Charset charset = Charset.forName("US-ASCII");
CxxConfiguration cxxConfig = new CxxConfiguration(charset, CxxFileTesterHelper.mockCxxLanguage());
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/TabCharacter.cc", ".", "US-ASCII");
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/TabCharacter.cc", ".", Charset.forName("US-ASCII"));
SourceFile file = CxxAstScanner.scanSingleFileConfig(CxxFileTesterHelper.mockCxxLanguage(), tester.cxxFile, cxxConfig, tester.sensorContext, check);

CheckMessagesVerifier.verify(file.getCheckMessages())
Expand All @@ -48,7 +48,7 @@ public void testAsciiFileAsciiEncoding() throws UnsupportedEncodingException, IO
public void testAsciiFileUtf8Encoding() throws UnsupportedEncodingException, IOException {
Charset charset = Charset.forName("UTF-8");
CxxConfiguration cxxConfig = new CxxConfiguration(charset, CxxFileTesterHelper.mockCxxLanguage());
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/TabCharacter.cc", ".", "UTF-8");
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/TabCharacter.cc", ".", Charset.forName("UTF-8"));
SourceFile file = CxxAstScanner.scanSingleFileConfig(CxxFileTesterHelper.mockCxxLanguage(), tester.cxxFile, cxxConfig, tester.sensorContext, check);

CheckMessagesVerifier.verify(file.getCheckMessages())
Expand All @@ -59,7 +59,7 @@ public void testAsciiFileUtf8Encoding() throws UnsupportedEncodingException, IOE
public void testUnicodeFileUtf16Encoding() throws UnsupportedEncodingException, IOException {
Charset charset = Charset.forName("UTF-16");
CxxConfiguration cxxConfig = new CxxConfiguration(charset, CxxFileTesterHelper.mockCxxLanguage());
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/Unicode.cc", ".", "UTF-16");
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/Unicode.cc", ".", Charset.forName("UTF-16"));
SourceFile file = CxxAstScanner.scanSingleFileConfig(CxxFileTesterHelper.mockCxxLanguage(), tester.cxxFile, cxxConfig, tester.sensorContext, check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.noMore();
Expand All @@ -69,7 +69,7 @@ public void testUnicodeFileUtf16Encoding() throws UnsupportedEncodingException,
public void testUnicodeFileAsciiEncoding() throws IOException {
Charset charset = Charset.forName("US-ASCII");
CxxConfiguration cxxConfig = new CxxConfiguration(charset, CxxFileTesterHelper.mockCxxLanguage());
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/Unicode.cc", ".", "US-ASCII");
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/Unicode.cc", ".", Charset.forName("US-ASCII"));
SourceFile file = CxxAstScanner.scanSingleFileConfig(CxxFileTesterHelper.mockCxxLanguage(), tester.cxxFile, cxxConfig, tester.sensorContext, check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().withMessage("Not all characters of the file can be encoded with the predefined charset " + charset.name() + ".")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void fileRegExCodingErrorActionReplace() throws UnsupportedEncodingExcept
check.regularExpression = "stdafx\\.h";
check.message = "Found 'stdafx.h' in file!";

CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/FileRegEx.cc", ".", "US-ASCII");
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/FileRegEx.cc", ".", Charset.forName("US-ASCII"));

SourceFile file = CxxAstScanner.scanSingleFileConfig(CxxFileTesterHelper.mockCxxLanguage(), tester.cxxFile, cxxConfig, tester.sensorContext, check);
CheckMessagesVerifier.verify(file.getCheckMessages())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;

import org.junit.Test;
import org.sonar.cxx.CxxAstScanner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
package org.sonar.cxx.checks;

import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
Expand Down
2 changes: 1 addition & 1 deletion cxx-checks/src/test/java/org/sonar/cxx/tag/TagTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import java.lang.reflect.Constructor;

import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;

public class TagTest {

Expand Down
7 changes: 4 additions & 3 deletions cxx-lint/src/main/java/org/sonar/cxx/cxxlint/CppLanguage.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
package org.sonar.cxx.cxxlint;

import java.util.List;
import org.sonar.api.config.Settings;

import org.sonar.api.config.Configuration;
import org.sonar.cxx.CxxLanguage;

/**
Expand All @@ -30,8 +31,8 @@
*/
public class CppLanguage extends CxxLanguage {

public CppLanguage() {
super("c++", new Settings());
public CppLanguage(Configuration config) {
super("c++", config);
}

@Override
Expand Down
Loading