2

How can I resolve this issue in IntellijIdea?

enter image description here

This answer Why no "field is never assigned" warning with @Mock only describe the reason but not offer the resolving.

Valentyn Hruzytskyi
  • 1,772
  • 5
  • 27
  • 59
  • What does `resetField` do? – Sweeper Oct 02 '19 at 06:42
  • @Sweeper This is not important. Those fields (@FindBy annotated) do "never assigned" in all classes and all methods. – Valentyn Hruzytskyi Oct 02 '19 at 07:26
  • did u check this https://www.igorkromin.net/index.php/2018/08/23/how-to-suppress-unused-method-inspection-in-intellij-for-a-specific-method/ https://stackoverflow.com/questions/6166334/disable-not-used-warning-for-public-methods-of-a-class – pvpkiran Oct 02 '19 at 08:07
  • @pvpkiran Done! You can be answered with this resolving, I will accept it. https://www.igorkromin.net/index.php/2018/08/23/how-to-suppress-unused-method-inspection-in-intellij-for-a-specific-method/ – Valentyn Hruzytskyi Oct 02 '19 at 08:59
  • Gr8. I haven't done anything. I do not deserve the point :) The answer was from https://stackoverflow.com/questions/6166334/disable-not-used-warning-for-public-methods-of-a-class. Just upvote there. :) – pvpkiran Oct 02 '19 at 09:00

2 Answers2

5

This warning is produced by the "Unused declaration" inspection, which does not know about the @FindBy annotation. To teach it, position the text cursor on the name of the field, type Alt+Enter and invoke the Suppress unused warning if annotated by '@FindBy' action. After that it will no longer warn on any field annotated by this annotation.

The action will add the intention to an internal "Mark field as implicitly written if annotated by" list. The setting can also be found in the settings of the inspection by clicking on the Annotations... button under the Entry points tab.

Bas Leijdekkers
  • 23,709
  • 4
  • 70
  • 68
2

To get rid of the warning you can add getter and setter for your fields.

public SelenideElement getOldPassword(){
    return this.oldPassword;
}

public void setOldPassword(SelenideElement oldPassword){
    this.oldPassword = oldPassword;
}
AndiCover
  • 1,724
  • 3
  • 17
  • 38