I have a couple of sets of EditText that i set to visible on a button click. In on my onClick, it is saying that my method is too complex to analyze by data flow algorithm. The code works fine when I run it. How can I remove this error? Or should i just ignore it since the the code is working fine? Any help would be appreciated, thanks.
public void showEditText(){ //method is too complex to analyze by data algorithm
if(!et1.isShown() && !et2.isShown()){
et1.setVisibility(View.VISIBLE);
et2.setVisibility(View.VISIBLE);
}else if(!et2.isShown() && !et3.isShown()){
et2.setVisibility(View.VISIBLE);
et3.setVisibility(View.VISIBLE);
}else if(!et4.isShown() && !et5.isShown()){
et4.setVisibility(View.VISIBLE);
et5.setVisibility(View.VISIBLE);
}else if(!et6.isShown() && !et7.isShown()){
et6.setVisibility(View.VISIBLE);
et7.setVisibility(View.VISIBLE);
}else if(!et8.isShown() && !et9.isShown()){
et8.setVisibility(View.VISIBLE);
et9.setVisibility(View.VISIBLE);
}else if(!et10.isShown() && !et11.isShown()){
et10.setVisibility(View.VISIBLE);
et11.setVisibility(View.VISIBLE);
}else if(!et12.isShown() && !et13.isShown()){
et12.setVisibility(View.VISIBLE);
et13.setVisibility(View.VISIBLE);
}else if(!et14.isShown() && !et15.isShown()){
et14.setVisibility(View.VISIBLE);
et15.setVisibility(View.VISIBLE);
}
You are getting the error because your code is too complex for IntelliJ's data flow algorithm. Instead of all the if else statements a more cleaner approach and ideally what you may want to do is pass the edittexts you want to show as arguments to the method:
public void showEditText(EditText et1, EditText et2) {
if(!et1.isShown() && !et2.isShown()){
et1.setVisibility(View.VISIBLE);
et2.setVisibility(View.VISIBLE);
}
}