Skip to content

Commit

Permalink
Merge branch 'release/3.0.0'
Browse files Browse the repository at this point in the history
# Conflicts:
#	esql-code-coverage/pom.xml
#	esql-plugin/pom.xml
#	pom.xml
  • Loading branch information
ThomasPohl committed Jan 5, 2020
2 parents 39002dc + b8415eb commit 76bde79
Show file tree
Hide file tree
Showing 673 changed files with 13,420 additions and 1,921 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ esql-frontend/.project
.settings/
.classpath
.project
.idea
*.iml
sampleWorkspace/.scannerwork
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This open source plugin can be used to analyze the ESQL-sourcecode of IBM Websph

## Requirements

- SonarQube 6.7
- SonarQube 7.9


## Contributing
Expand All @@ -32,6 +32,7 @@ This open source plugin can be used to analyze the ESQL-sourcecode of IBM Websph

## History

- 3.0.0 - Bugfixes, upgrade to sonar SonarQube 7.9
- 2.3.0 - Additional rules, upgrade to SonarQube 6.7, copy paste detector
- 2.2.0 - Code coverage analysis
- 2.1.0 - A few bugfixes and a lot more checks/rules
Expand All @@ -43,7 +44,7 @@ This open source plugin can be used to analyze the ESQL-sourcecode of IBM Websph

## Credits

- EXXETA AG
- [EXXETA AG](http://exxeta.com)
- See [Contributors](https://www.github.com/EXXETA/sonar-esql-plugin/graphs/contributors)

## License
Expand Down
4 changes: 2 additions & 2 deletions esql-checks-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>com.exxeta.iss</groupId>
<artifactId>sonar-esql-plugin</artifactId>
<version>2.3.5</version>
<version>0.0.1-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -37,7 +37,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<artifactId>mockito-core</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package com.exxeta.iss.sonar.esql.checks.verifier;

import java.text.MessageFormat;
import java.util.Arrays;

public class CheckMessage {
private Integer line;
private Double cost;
private final Object check;
private final String defaultMessage;
private final Object[] messageArguments;
private Boolean bypassExclusion;

public CheckMessage(Object check, String message, Object... messageArguments) {
this.check = check;
this.defaultMessage = message;
this.messageArguments = messageArguments;
}

public void setLine(int line) {
this.line = line;
}


public Integer getLine() {
return line;
}

public void setCost(double cost) {
this.cost = cost;
}

public Double getCost() {
return cost;
}

public void setBypassExclusion(boolean bypassExclusion) {
this.bypassExclusion = bypassExclusion;
}

public boolean isBypassExclusion() {
return bypassExclusion != null && bypassExclusion;
}


public Object getCheck() {
return check;
}

public String getDefaultMessage() {
return defaultMessage;
}

public Object[] getMessageArguments() {
return messageArguments;
}


public String getText() {
return formatDefaultMessage();
}

@Override
public String toString() {
return "CheckMessage{" +
"line=" + line +
", cost=" + cost +
", check=" + check +
", defaultMessage='" + defaultMessage + '\'' +
", messageArguments=" + Arrays.toString(messageArguments) +
", bypassExclusion=" + bypassExclusion +
'}';
}

public String formatDefaultMessage() {
if (messageArguments.length == 0) {
return defaultMessage;
} else {
return MessageFormat.format(defaultMessage, messageArguments);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package com.exxeta.iss.sonar.esql.checks.verifier;

import com.google.common.collect.Ordering;
import org.hamcrest.Matcher;
import com.google.common.base.Objects;

import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;

import static org.junit.Assert.assertThat;

/**
* This class was copy&pasted from sslr-squid-bridge to avoid dependency on it
* <p>
* Helper class for testing checks without having to deploy them on a Sonar instance.
* It can be used as following:
* <pre>{@code
* CheckMessagesVerifier.verify(messages)
* .next().atLine(1).withMessage("foo")
* .next().atLine(2).withMessage("bar")
* .noMore();
* }</pre>
* Strictly speaking this is just a wrapper over collection of {@link CheckMessage},
* which guarantees order of traversal.
*
* @since sslr-squid-bridge 2.1
*/
public final class CheckMessagesVerifier {

private final Iterator<CheckMessage> iterator;
private CheckMessage current;

private static final Comparator<CheckMessage> ORDERING = (left, right) -> {
if (Objects.equal(left.getLine(), right.getLine())) {
return left.getDefaultMessage().compareTo(right.getDefaultMessage());
} else if (left.getLine() == null) {
return -1;
} else if (right.getLine() == null) {
return 1;
} else {
return left.getLine().compareTo(right.getLine());
}
};

private CheckMessagesVerifier(Collection<CheckMessage> messages) {
iterator = Ordering.from(ORDERING).sortedCopy(messages).iterator();
}

public static CheckMessagesVerifier verify(Collection<CheckMessage> messages) {
return new CheckMessagesVerifier(messages);
}

public CheckMessagesVerifier next() {
if (!iterator.hasNext()) {
throw new AssertionError("\nExpected violation");
}
current = iterator.next();
return this;
}

public void noMore() {
if (iterator.hasNext()) {
CheckMessage next = iterator.next();
throw new AssertionError("\nNo more violations expected\ngot: at line " + next.getLine());
}
}

private void checkStateOfCurrent() {
if (current == null) {
throw new IllegalStateException("Prior to this method you should call next()");
}
}

public CheckMessagesVerifier atLine(@Nullable Integer expectedLine) {
checkStateOfCurrent();
if (!Objects.equal(expectedLine, current.getLine())) {
throw assertionError(expectedLine, current.getLine());
}
return this;
}

public CheckMessagesVerifier withMessage(String expectedMessage) {
checkStateOfCurrent();
String actual = current.getText();
if (!actual.equals(expectedMessage)) {
throw assertionError("\"" + expectedMessage + "\"", "\"" + actual + "\"");
}
return this;
}

/**
* Note that this method requires JUnit and Hamcrest.
*/
CheckMessagesVerifier withMessageThat(Matcher<String> matcher) {
checkStateOfCurrent();
String actual = current.getText();
assertThat(actual, matcher);
return this;
}

/**
* @since sslr-squid-bridge 2.3
*/
CheckMessagesVerifier withCost(Double expectedCost) {
checkStateOfCurrent();
if (!Objects.equal(expectedCost, current.getCost())) {
throw assertionError(expectedCost, current.getCost());
}
return this;
}

private static AssertionError assertionError(@Nullable Object expected, @Nullable Object actual) {
return new AssertionError("\nExpected: " + expected + "\ngot: " + actual);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Sonar ESQL Plugin
* Copyright (C) 2013-2018 Thomas Pohl and EXXETA AG
* Copyright (C) 2013-2020 Thomas Pohl and EXXETA AG
* http://www.exxeta.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -26,7 +26,6 @@
import java.util.List;

import org.sonar.api.batch.fs.InputFile;
import org.sonar.squidbridge.checks.CheckMessagesVerifier;

import com.exxeta.iss.sonar.esql.api.EsqlCheck;
import com.exxeta.iss.sonar.esql.api.visitors.EsqlVisitorContext;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Sonar ESQL Plugin
* Copyright (C) 2013-2018 Thomas Pohl and EXXETA AG
* Copyright (C) 2013-2020 Thomas Pohl and EXXETA AG
* http://www.exxeta.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Sonar ESQL Plugin
* Copyright (C) 2013-2018 Thomas Pohl and EXXETA AG
* Copyright (C) 2013-2020 Thomas Pohl and EXXETA AG
* http://www.exxeta.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Sonar ESQL Plugin
* Copyright (C) 2013-2018 Thomas Pohl and EXXETA AG
* Copyright (C) 2013-2020 Thomas Pohl and EXXETA AG
* http://www.exxeta.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Sonar ESQL Plugin
* Copyright (C) 2013-2018 Thomas Pohl and EXXETA AG
* Copyright (C) 2013-2020 Thomas Pohl and EXXETA AG
* http://www.exxeta.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -22,7 +22,6 @@
import java.util.List;

import org.sonar.api.batch.fs.InputFile;
import org.sonar.squidbridge.api.CheckMessage;

import com.exxeta.iss.sonar.esql.api.EsqlCheck;
import com.exxeta.iss.sonar.esql.api.visitors.EsqlVisitorContext;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Sonar ESQL Plugin
* Copyright (C) 2013-2018 Thomas Pohl and EXXETA AG
* Copyright (C) 2013-2020 Thomas Pohl and EXXETA AG
* http://www.exxeta.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion esql-checks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.exxeta.iss</groupId>
<artifactId>sonar-esql-plugin</artifactId>
<version>2.3.5</version>
<version>0.0.1-SNAPSHOT</version>
</parent>

<artifactId>esql-checks</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Sonar ESQL Plugin
* Copyright (C) 2013-2018 Thomas Pohl and EXXETA AG
* Copyright (C) 2013-2020 Thomas Pohl and EXXETA AG
* http://www.exxeta.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Sonar ESQL Plugin
* Copyright (C) 2013-2018 Thomas Pohl and EXXETA AG
* Copyright (C) 2013-2020 Thomas Pohl and EXXETA AG
* http://www.exxeta.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Sonar ESQL Plugin
* Copyright (C) 2013-2018 Thomas Pohl and EXXETA AG
* Copyright (C) 2013-2020 Thomas Pohl and EXXETA AG
* http://www.exxeta.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -55,4 +55,4 @@ public void visitProgram(ProgramTree tree) {
}
}
}
}
}
Loading

0 comments on commit 76bde79

Please sign in to comment.