Skip to content

Commit

Permalink
INTSAMPLES-143: Fix Package Tangles
Browse files Browse the repository at this point in the history
JIRA: https://jira.spring.io/browse/INTSAMPLES-143

Add Sonar support to build.gradle.

Fix critical violations.
  • Loading branch information
garyrussell authored and artembilan committed Jul 30, 2015
1 parent 70b4d12 commit 61603c2
Show file tree
Hide file tree
Showing 36 changed files with 193 additions and 118 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,6 +20,7 @@

/**
* @author Oleg Zhurakousky
* @author Gary Russell
*/
public class LoanQuote implements Comparable<LoanQuote>{

Expand Down Expand Up @@ -78,8 +79,9 @@ public void setRate(float rate) {
this.rate = rate;
}

@Override
public int compareTo(LoanQuote other) {
if (this.rate > other.rate) {
if (this.rate > other.rate) { //NOSONAR
return 1;
}
else if (this.rate < other.rate) {
Expand All @@ -88,8 +90,9 @@ else if (this.rate < other.rate) {
return 0;
}

@Override
public String toString() {
return this.lender + ":\t" + this.rate;
return this.lender + ":\t" + this.rate;
}

}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -38,13 +38,13 @@ public void accumulate(SharkQuote quote) {
if (shark == null) {
shark = new LoanShark();
shark.setName(quote.getSharkName());
shark.setCounter(new Long(0));
shark.setCounter(Long.valueOf(0));
shark.setAverageRate(0.0d);
shark.persist();
}
Double current = shark.getCounter() * shark.getAverageRate();
shark.setCounter(shark.getCounter().longValue() + 1);
shark.setAverageRate((current + quote.getSharkRate()) / shark.getCounter());
}

}
Expand Up @@ -22,6 +22,7 @@
import org.apache.log4j.Logger;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.samples.enricher.domain.User;
import org.springframework.integration.samples.enricher.service.UserService;


Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand All @@ -10,31 +10,34 @@
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package org.springframework.integration.samples.enricher;
package org.springframework.integration.samples.enricher.domain;

public class User {
private String username;
private String password;
private String email;

public User(String username, String password, String email) {
super();
this.username = username;
this.password = password;
this.email = email;
}
private String username;

public String getUsername() {
return this.username;
}
private String password;

public String getPassword() {
return this.password;
}
private String email;

public String getEmail() {
return this.email;
}
public User(String username, String password, String email) {
super();
this.username = username;
this.password = password;
this.email = email;
}

public String getUsername() {
return this.username;
}

public String getPassword() {
return this.password;
}

public String getEmail() {
return this.email;
}

public void setUsername(String username) {
this.username = username;
Expand All @@ -51,12 +54,8 @@ public void setEmail(String email) {
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("User [username=")
.append(this.username)
.append(", password=")
.append(this.password)
.append(", email=")
.append(this.email).append("]");
builder.append("User [username=").append(this.username).append(", password=").append(this.password)
.append(", email=").append(this.email).append("]");
return builder.toString();
}

Expand Down
Expand Up @@ -17,7 +17,7 @@

import java.util.Map;

import org.springframework.integration.samples.enricher.User;
import org.springframework.integration.samples.enricher.domain.User;

/**
* Provides user services.
Expand Down
Expand Up @@ -16,7 +16,8 @@
package org.springframework.integration.samples.enricher.service.impl;

import org.apache.log4j.Logger;
import org.springframework.integration.samples.enricher.User;

import org.springframework.integration.samples.enricher.domain.User;

/**
* Simple Service class for retrieving user information.
Expand Down
Expand Up @@ -22,7 +22,7 @@

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.samples.enricher.User;
import org.springframework.integration.samples.enricher.domain.User;


/**
Expand Down
Expand Up @@ -24,6 +24,8 @@
import org.apache.log4j.Logger;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.samples.jdbc.domain.Gender;
import org.springframework.integration.samples.jdbc.domain.Person;
import org.springframework.integration.samples.jdbc.service.PersonService;


Expand Down
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.samples.jdbc;
package org.springframework.integration.samples.jdbc.domain;

import java.util.EnumSet;
import java.util.HashMap;
Expand Down
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.samples.jdbc;
package org.springframework.integration.samples.jdbc.domain;

import java.util.Date;

Expand Down
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.samples.jdbc;
package org.springframework.integration.samples.jdbc.domain;

import java.sql.ResultSet;
import java.sql.SQLException;
Expand Down
Expand Up @@ -10,7 +10,7 @@
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package org.springframework.integration.samples.jdbc;
package org.springframework.integration.samples.jdbc.domain;

public class User {
private String username;
Expand Down
Expand Up @@ -10,7 +10,7 @@
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package org.springframework.integration.samples.jdbc;
package org.springframework.integration.samples.jdbc.domain;

import java.sql.ResultSet;
import java.sql.SQLException;
Expand Down
Expand Up @@ -18,7 +18,7 @@

import java.util.List;

import org.springframework.integration.samples.jdbc.Person;
import org.springframework.integration.samples.jdbc.domain.Person;

/**
* The Service used to create Person instance in database
Expand Down
Expand Up @@ -46,7 +46,7 @@



<bean id="personResultMapper" class="org.springframework.integration.samples.jdbc.PersonMapper"/>
<bean id="personResultMapper" class="org.springframework.integration.samples.jdbc.domain.PersonMapper"/>
<int-jdbc:outbound-gateway data-source="datasource"
request-channel="createPersonRequestChannel"
reply-channel="createPersonReplyChannel"
Expand Down
Expand Up @@ -22,6 +22,8 @@
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.samples.jdbc.domain.Gender;
import org.springframework.integration.samples.jdbc.domain.Person;
import org.springframework.integration.samples.jdbc.service.PersonService;

/**
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,6 +20,7 @@
import java.util.Scanner;

import org.springframework.context.support.GenericXmlApplicationContext;
import org.springframework.integration.samples.jpa.domain.Person;
import org.springframework.integration.samples.jpa.service.PersonService;
import org.springframework.util.StringUtils;

Expand All @@ -28,6 +29,7 @@
*
* @author Gunnar Hillert
* @author Amol Nayak
* @author Gary Russell
* @version 1.0
*
*/
Expand Down Expand Up @@ -104,13 +106,16 @@ public static void main(final String... args) {
while (true) {
final String input = scanner.nextLine();

if("1".equals(input.trim())) {
if ("1".equals(input.trim())) {
findPeople(personService);
} else if("2".equals(input.trim())) {
createPersonDetails(scanner,personService);
} else if("q".equals(input.trim())) {
}
else if ("2".equals(input.trim())) {
createPersonDetails(scanner, personService);
}
else if ("q".equals(input.trim())) {
break;
} else {
}
else {
System.out.println("Invalid choice\n\n");
}

Expand All @@ -122,6 +127,7 @@ public static void main(final String... args) {
}

System.out.println("Exiting application...bye.");
context.close();
System.exit(0);

}
Expand Down Expand Up @@ -169,7 +175,7 @@ private static void findPeople(final PersonService service) {
if(people != null && !people.isEmpty()) {
for(Person person : people) {
System.out.print(String.format("%d, %s, ", person.getId(), person.getName()));
System.out.println(DATE_FORMAT.format(person.getCreatedDateTime()));
System.out.println(DATE_FORMAT.format(person.getCreatedDateTime()));//NOSONAR
}
} else {
System.out.println(
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.samples.jpa;
package org.springframework.integration.samples.jpa.domain;

import java.util.Date;

Expand Down
Expand Up @@ -18,7 +18,7 @@

import java.util.List;

import org.springframework.integration.samples.jpa.Person;
import org.springframework.integration.samples.jpa.domain.Person;
import org.springframework.messaging.handler.annotation.Payload;

/**
Expand Down
Expand Up @@ -22,6 +22,7 @@
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.samples.jpa.domain.Person;
import org.springframework.integration.samples.jpa.service.PersonService;

/**
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,14 +25,15 @@

/**
* @author Mark Fisher
* @author Gary Russell
*/
@MessageEndpoint
public class QuoteService {

@ServiceActivator(inputChannel="tickers", outputChannel="quotes")
public Quote lookupQuote(String ticker) {
BigDecimal price = new BigDecimal(new Random().nextDouble() * 100);
return new Quote(ticker, price.setScale(2, RoundingMode.HALF_EVEN));
BigDecimal price = new BigDecimal(new Random().nextDouble() * 100);//NOSONAR
return new Quote(ticker, price.setScale(2, RoundingMode.HALF_EVEN));
}

}

0 comments on commit 61603c2

Please sign in to comment.