Method Returns the Same Value  

 

Method Returns the Same Value 검사는 그들이 불려질 때마다 같은 값을 반환하는 메소드를 검색합니다.

만일 Method returns the same value   체크 박스가 선택되고 Inspection 어떤 문제를 찾으면, Inspection 윈도우는 항상 같은 값을 반환하는 메소드를 보여주는 Same return value  탭을 표시합니다.

검사에 의해 발견된 문제에 대한 어떤 사전 정의의 솔루션도 없습니다.


검사는 어떤 옵션도 가지지 않습니다.


 

사용



다음 코드를 보십시오:

 
public interface AnInterface {
    boolean methodA(int myInt);
}
 
public class AClass implements AnInterface {
    public boolean methodA(int myInt) {
        if(myInt > 0){
        return true;
    } else {
        return true;
    }
}
 
public void methodB() {
    if(methodA(1) == true){
        //some code here
        }
    }
}
 
public class AClassTwo implements AnInterface {
 
    public boolean methodA(int myInt) {
        //some code here
        return true;
    }
 
    boolean methodB(int i) {
        if (i > 0) {
            return true;
        } else {
            return false;
        }
    }
}

 

Inspection  주어진 인터페이스와 클래스를 포함하고 있는 패키지에 적용되고 후에다음의 윈도우가 나타날 것입니다.



methodA 지적되었습니다모든 메소드 구현의 반환값은 항상 같은 것입니다.