Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@ static <T> Optional<T> forEditorInputDo(IEditorInput i, Function<ITypeRoot, Opti
}

static Function<ITypeRoot, Optional<IResource>> getCorrespondingResource() {
return new Function<ITypeRoot, Optional<IResource>>() {
public Optional<IResource> apply(ITypeRoot t) {
try {
return Optional.ofNullable(t.getCorrespondingResource());
} catch (JavaModelException e) {
return Optional.empty();
}
return t -> {
try {
return Optional.ofNullable(t.getCorrespondingResource());
} catch (JavaModelException e) {
return Optional.empty();
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,11 @@ public class SocketProvider {
* @return an object allowing to write and read objects from the given port
*/
public ObjectStreamSocket listen(int portNumber) {
ServerSocket serverSocket = null;
try {
serverSocket = new ServerSocket(portNumber);
try (ServerSocket serverSocket = new ServerSocket(portNumber)) {
Socket connection = serverSocket.accept();
return ObjectStreamSocket.make(connection);
} catch (IOException e) {
throw new SocketCreationException(e);
} finally {
ensureClosed(serverSocket);
}
}

Expand Down Expand Up @@ -92,7 +88,7 @@ public Optional<ObjectStreamSocket> connectTo(int portNumber) {
private Optional<ObjectStreamSocket> doConnect(int portNumber) {
try {
InetAddress localhost = InetAddress.getByName(null);
Socket socket = new Socket();
Socket socket = new Socket(); // NOSONAR the socket is used in a returned object
SocketAddress endpoint = new InetSocketAddress(localhost, portNumber);
socket.connect(endpoint, DEFAULT_TIMEOUT);
return Optional.of(ObjectStreamSocket.make(socket));
Expand All @@ -106,31 +102,10 @@ private Optional<ObjectStreamSocket> doConnect(int portNumber) {
* @return the number of a port that can be used
*/
public int getFreePort() {
ServerSocket socket = null;
try {
socket = new ServerSocket(0);
try (ServerSocket socket = new ServerSocket(0)) {
return socket.getLocalPort();
} catch (IOException e) {
throw new SocketCreationException(e);
} finally {
if (socket != null) {
try {
socket.close();
} catch (IOException e) {
System.out.println("Warning, did not close socket");
e.printStackTrace();
}
}
}
}

private void ensureClosed(ServerSocket serverSocket) {
try {
if (null != serverSocket) {
serverSocket.close();
}
} catch (IOException e) {
throw new SocketCreationException(e);
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ public void setup() {
}

@Test
public void noMutations() {
public void noMutations() { // NOSONAR: assertions made by called methods
givenNoMutations();
whenPitIsExecuted();
thenTheResultsWere(empty());
}

@Test
public void aClassMutationResultFromPitIsConvertedAndDispatched() {
public void aClassMutationResultFromPitIsConvertedAndDispatched() { // NOSONAR: assertions made by called methods
given(aClassMutationResult());
whenPitIsExecuted();
thenTheResultsWere(aMutationResult());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@

public class SummaryResultListenerTest {
@Test
public void noResultsReturnsAnEmptyResult() {
public void noResultsReturnsAnEmptyResult() { // NOSONAR: assertions made by called methods
given(anEmptyCoverageDatabase())
.andNoMutations()
.whenPitIsExecuted()
.thenTheResultsAre(empty());
}

@Test
public void anUncoveredMutationResultReturnsZeroLineCoverage() {
public void anUncoveredMutationResultReturnsZeroLineCoverage() { // NOSONAR: assertions made by called methods
given(fooHasNoLineCoverage())
.and(anUncoveredMutationOnFoo())
.whenPitIsExecuted()
Expand All @@ -48,7 +48,7 @@ public void anUncoveredMutationResultReturnsZeroLineCoverage() {
}

@Test
public void aCoveredMutationResultReturnsLineCoverage() {
public void aCoveredMutationResultReturnsLineCoverage() { // NOSONAR: assertions made by called methods
given(fooHasFullLineCoverage())
.and(aCoveredMutationOnFoo())
.whenPitIsExecuted()
Expand Down