Skip to content

Commit

Permalink
Merge pull request #1046 from DevFactory/release/equals-methods-shoul…
Browse files Browse the repository at this point in the history
…d-be-symmetric-and-work-for-subclasses,-Local-Variables-should-not-be-declared-and-then-immediately-returned-or-thrown-fix-1

squid:S2162, squid:S1488 - equals methods should be symmetric and wor…
  • Loading branch information
Turini committed Feb 4, 2016
2 parents 2e8b207 + f6c7c87 commit 9c37e62
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public Annotation[] getDeclaredAnnotations() {

@Override
public boolean equals(Object obj) {
if (obj instanceof Parameter) {
if (this.getClass() == obj.getClass()) {
Parameter other = (Parameter) obj;
return other.index == index && other.holder.equals(holder);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void setValue(Object value) {

@Override
public boolean equals(Object obj) {
if (obj instanceof ValuedParameter) {
if (this.getClass() == obj.getClass()) {
ValuedParameter other = (ValuedParameter) obj;
return Objects.equals(parameter.getName(), other.getParameter().getName())
&& Objects.equals(value, other.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,10 @@ public void add(Music music) {

@Override
public List<Music> searchSimilarTitle(String title) {
List<Music> musics = entityManager
.createQuery("select m from Music m where lower(m.title) like lower(:title)", Music.class)
return musics = entityManager
.createQuery("select m from Music m where lower(m.title) like lower(:title)", Music.class)
.setParameter("title", "%" + title+ "%")
.getResultList();
return musics;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@ public DefaultUserDao(EntityManager entityManager) {
@Override
public User find(String login, String password) {
try {
User user = entityManager
.createQuery("select u from User u where u.login = :login and u.password = :password", User.class)
return entityManager
.createQuery("select u from User u where u.login = :login and u.password = :password", User.class)
.setParameter("login", login)
.setParameter("password", password)
.getSingleResult();
return user;
} catch (NoResultException e) {
return null;
}
Expand Down

0 comments on commit 9c37e62

Please sign in to comment.