Questions tagged [intellij-inspections]

37 questions
761
votes
63 answers

IntelliJ inspection gives "Cannot resolve symbol" but still compiles code

Platform: IntelliJ Community Edition 10.0.3 SDK: jdk1.6.0_21 OS: Windows 7 So I have a strange situation with IntelliJ that has me completely stumped. I setup a Maven project and add log4j as a dependency in the pom.xml file. The IDEA inspections…
Kevin Sitze
  • 8,029
  • 3
  • 16
  • 19
144
votes
31 answers

IntelliJ IDEA shows errors when using Spring's @Autowired annotation

IntelliJ IDEA is showing errors when I use Spring's @Autowired annotation in the class, but the class is functioning without any problem. Here is this error message: Autowired members must be defined in the valid spring bean…
Vainlyh
  • 1,615
  • 2
  • 12
  • 11
27
votes
2 answers

Why does IntelliJ suggest to convert a call chain into a Sequence?

Assume the following Kotlin example that maps the source set src to a destination set dst: private val src: Set = setOf("hello", "world") private val dst: Set = src.map { it.length }.toSet() This works fine. However, IntelliJ's code…
7
votes
1 answer

IntelliJ inspection: 'Method invocation may produce NullPointerException'. Does the suggested fix make sense?

I commonly come across the following IntelliJ inspection private boolean bar() { return foo().contains("foo"); // Method invocation 'contains' may produce 'java.lang.NullPointerException' } private String foo() { return null; } The…
A1m
  • 2,897
  • 2
  • 24
  • 39
7
votes
4 answers

How to disable code inspection errors in README.md file in Android Studio

In my GitHub README.md file, which is in the root of my Android project, I have code snippets like the following ones: ```xml android:windowSoftInputMode="stateHidden" ``` ```java MongolToast.makeText(getApplicationContext(), "ᠰᠠᠢᠨ ᠪᠠᠢᠨ᠎ᠠ ᠤᠤ︖",…
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
6
votes
2 answers

Pycharm - Disable 'Local variable 'xxx' might be referenced before assignment'

In pycharm, I would like to disable the following inspection warn: "Local variable 'xxx' might be referenced before assignment" but I can't find it in settings/inspections. PS: This is not a duplicate, as I understand this warn. I am just asking how…
u2gilles
  • 6,888
  • 7
  • 51
  • 75
3
votes
2 answers

Why does IntelliJ wants me to change this?

A simple line of code: String thing = "Something"; thing += " something else" + " and more."; IntelliJ IDEA offers to change this line into 4 other ways to accomplish the same…
3
votes
1 answer

Is it possible to disable "Optional used as field or parameter type" inspection in IntelliJ for private methods?

I don't want to disable the warning altogether and I already know why you supposedly shouldn't use Optional as a parameter. However, I don't think it's relevant to my case. For illustrative purposes, I have code that looks like this: //IntelliJ…
VLAZ
  • 26,331
  • 9
  • 49
  • 67
3
votes
1 answer

Prevent Android Studio Inspection from Flagging Java Stream chain as containing possible NullPointerException

I'm writing a utility method to extract an array of wrapped unparcelable objects: public interface UnparcelableHolder { @Nullable U getUnparcelable(); } public final class FragmentUtil { @Nullable public static List
2
votes
1 answer

How to write custom inspection for duplicate annotations in Intellij Idea?

Test methods is annotated with values, this values must be uniq. I want an inspection in IDEA that highlights duplicate annotation. Duplicates may be in different java files Example @Link(type = "manual", value = "123456")<-this must be…
2
votes
3 answers

Warnings don't work about unresolved references after using development install

I have a bug with PyCharm, after I use development install pip install -v -e . the IDE does not warn me about any unresolved references. For example, with unresolved references normally you get this: But now after development install unresolved…
bad_coder
  • 11,289
  • 20
  • 44
  • 72
1
vote
1 answer

How to suppress operator overloading for get and set methods in Kotlin inspections?

I am trying to create a custom get and set method but I would like to suppress the inspections warning Function should have 'operator' modifier only for these specific functions. The following did not work: @Suppress("operator") suspend fun get(key:…
semantic_c0d3r
  • 491
  • 1
  • 4
  • 18
1
vote
0 answers

How can I declare what class a YAML.load() will return so that my IDE will properly identify the loaded object in inspections?

I have a class, JsonConnection. I serialize an instance of that class, connection, to YAML, and store it: connection = JsonConnection.new session[:con] = connection.to_yaml Later, I use the JsonConnection deserialized from the storage throughout my…
David Gay
  • 1,094
  • 2
  • 16
  • 32
1
vote
0 answers

How to delete inspection profiles in Intellij?

I'm unable to delete inspection profiles in IntelliJ. I can choose one of my custom profiles and click on the "Delete ..." menu item. This removes it from the Profile drop down list. If I click "Ok" at the dialog window and then open it again all…
BetaRide
  • 16,207
  • 29
  • 99
  • 177
1
vote
1 answer

Does IntelliJ's search template language have a way to identify function calls not wrapped by an if statement

I'm looking at some legacy code in PhpStorm and there are some instances within the codebase where a particular function call is wrapped by another function call within an if statement e.g. if (thisIsTrue($param1, $param2)) { // possibly some…
1
2 3