public Meteo getMeteoTorneo() {
Meteo meteo = new Meteo(cittaString);
Document doc = null;
try {
doc = Jsoup.connect("https://www.ilmeteo.it/meteo/" + torneo.getCitta()).get();
} catch (IOException e) {
e.printStackTrace();
}
Elements newsHeadlines = doc.getElementsByTag("li");
for (Element headline : newsHeadlines) {
if (headline.text().split(" ").length > 2) {
String tmax = headline.getElementsByClass("tmax").text();
String tmin = headline.getElementsByClass("tmin").text();
String giorno = headline.getElementsByTag("span").first() != null ? headline.getElementsByTag("span").first().text() : "";
boolean rain = headline.getElementsByClass("s flag_pioggia").isEmpty();
boolean nuvoloso = headline.getElementsByClass("s ss3").isEmpty();
boolean sole = headline.getElementsByClass("s ss1").isEmpty();
if(controllaTemp(tmin, tmax))
continue;
if((controllaData() && (giorno.split(" ")[1].equals(""+torneo.getData().getDayOfMonth())))){
if(!rain)
meteo.setT("1");
else if(!nuvoloso)
meteo.setT("2");
else if(!sole)
meteo.setT("3");
meteo.settMin(tmin);
meteo.settMax(tmax);
}
}
}
return meteo;
}
Hi, I have a problem with this method. Sonar tells me to reduce its Cognitive Complexity from 21 to the 15 allowed, but I have no idea what I have to do, because I can remove nothing. Could you suggest something? Thanks