# Why does VSCode say there is a problem in this code?

**URL:** https://discourse.julialang.org/t/why-does-vscode-say-there-is-a-problem-in-this-code/73280
**Category:** General Usage
**Tags:** vscode
**Created:** [December 17, 2021, 7:19pm UTC](https://discourse.julialang.org/t/why-does-vscode-say-there-is-a-problem-in-this-code/73280 "2021-12-17T19:19:43Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Soldalma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/soldalma/32/29388_2.png) [@Soldalma](https://discourse.julialang.org/u/Soldalma)
#### Post date: [December 17, 2021, 7:19pm UTC](https://discourse.julialang.org/t/why-does-vscode-say-there-is-a-problem-in-this-code/73280/1 "2021-12-17T19:19:43Z")

</div>

I created a file with the exact contents below. It runs fine, but `VSCode` keeps listing the file and the line with the `select` statement in the `Problems` tab.

Three questions:

1. What is the problem?  
My guess is that it is related to the function `delcol` having no information about the columns of its argument. But this is not clear.

2. How can I find what is the problem? (I tried)

3. How do I stop `VSCode` from listing this as a Problem, given that the code runs fine?

```julia
using DataFrames
df = DataFrame(A = [1,2,3], B = [4,5,6], C = ["C", "D", "E"])

function delcol(df1)
    select(df1, Not([:A]))
end 

delcol(df)

```

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [December 17, 2021, 8:39pm UTC](https://discourse.julialang.org/t/why-does-vscode-say-there-is-a-problem-in-this-code/73280/2 "2021-12-17T20:39:35Z")

</div>

Have you tried looking in the “Problem” tab of the terminal?

![image](https://global.discourse-cdn.com/julialang/original/3X/c/3/c3c782fe5d6b92ca2a2b92edecd896680c480a94.png)

no problems are reported for me

(fwiw, this is probably just an MWE, but that function seems a bit superfluous?)

---

<div class="post-metadata">

### Author: ![Soldalma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/soldalma/32/29388_2.png) [@Soldalma](https://discourse.julialang.org/u/Soldalma)
#### Post date: [December 17, 2021, 9:21pm UTC](https://discourse.julialang.org/t/why-does-vscode-say-there-is-a-problem-in-this-code/73280/3 "2021-12-17T21:21:25Z")

</div>

It was in the `Problems` tab that I saw there was a problem. It says there:

`Possible method call error. Julia[4, 17]`

I need to be able to delete a column of a DataFrame that was defined outside of a function. The function `delcol` does that, but I get the message above. It would be best to eliminate it.

There are other ways of deleting a column. For example, I could work with `names(df)`, delete from it the undesired column name, and then call `select` with the shorter list of column names. I might end up going that way.

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [December 17, 2021, 9:23pm UTC](https://discourse.julialang.org/t/why-does-vscode-say-there-is-a-problem-in-this-code/73280/4 "2021-12-17T21:23:53Z")

</div>

> [@Soldalma](#):
>
> `delcol`

I thought it’s `deleteat!(df::DataFrame, inds)` now

---

<div class="post-metadata">

### Author: ![Soldalma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/soldalma/32/29388_2.png) [@Soldalma](https://discourse.julialang.org/u/Soldalma)
#### Post date: [December 17, 2021, 9:49pm UTC](https://discourse.julialang.org/t/why-does-vscode-say-there-is-a-problem-in-this-code/73280/5 "2021-12-17T21:49:29Z")

</div>

According to the documentation in

[Functions · DataFrames.jl (juliadata.org)](https://dataframes.juliadata.org/stable/lib/functions/) "

`deleteat` deletes rows and `inds must be: a vector of sorted and unique integers, a boolean vector, an integer, or `Not` wrapping any valid selector.`

I want to use a symbol or a string to choose a column.

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [December 17, 2021, 10:20pm UTC](https://discourse.julialang.org/t/why-does-vscode-say-there-is-a-problem-in-this-code/73280/6 "2021-12-17T22:20:16Z")

</div>

my bad, I think what you’re looking for is:  
[select!](https://dataframes.juliadata.org/stable/lib/functions/#DataFrames.select!)

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [December 17, 2021, 10:50pm UTC](https://discourse.julialang.org/t/why-does-vscode-say-there-is-a-problem-in-this-code/73280/7 "2021-12-17T22:50:47Z")

</div>

Okay so there you have the problem - it’s a possible method call error. Of course in this case it isn’t an actual method call error, as the call signature `select(::DataFrame, ::InvertedIndex)` exists, so there’s a problem in how the Julia extension finds the method definitions for your code. Have you activated an environment that has DataFrames in it?

To answer your third question, you can disable this linter option in the extension settings:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/8/6/868052ce08dc8f6b75391bdb525abf5127667efa.png)

And finally `select!` is indeed the way to remove a column from an existing DataFrame in place, I still don’t understand why you define a function that does nothing else than call the select function rather than just using the select function. Also you can do `Not(:A)`, no need to create a one-element vector in the inverted index.

---

<div class="post-metadata">

### Author: ![Soldalma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/soldalma/32/29388_2.png) [@Soldalma](https://discourse.julialang.org/u/Soldalma)
#### Post date: [December 18, 2021, 12:20pm UTC](https://discourse.julialang.org/t/why-does-vscode-say-there-is-a-problem-in-this-code/73280/8 "2021-12-18T12:20:53Z")

</div>

The package `DataFrames` is part of the environment.

Thanks for the info on disabling lint. I could not install package Lint, though:

```julia
(BW1) pkg> add Lint
    Updating registry at `C:\Users\fsald\.julia\registries\General`
    Updating git-repo `https://github.com/JuliaRegistries/General.git`
ERROR: The following package names could not be resolved:
 * Lint (not found in project, manifest or registry)

```

From inside Julia with `Pkg.add("Lint")` also did not work.

In my original code I have a function that receives a dataframe as an argument, removes a column from that dataframe, and adds newly calculated columns to that same dataframe. That function was quite complex, as it also performed other unrelated tasks. It wasn’t fit to be posted “as is,” since Julia Discourse’s guidelines ask for MWEs. For this reason I removed from it the unrelated tasks, trying to generate a MWE. What remained looked like a function that just wraps a `select` statement, which of course is not a very interesting function by itself.

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [December 18, 2021, 12:34pm UTC](https://discourse.julialang.org/t/why-does-vscode-say-there-is-a-problem-in-this-code/73280/9 "2021-12-18T12:34:57Z")

</div>

But I assume the actual MWE in your code would have been

```julia
select(df, :A)

```

or not? Are there differences in the linter result between the function you defined and other calls to `select`?

Lint is not a package, linting is the process of running an automated code-checker to identify issues in your code. The Julia VSCode extension has in inbuilt linter, and the screenshot I shared was a screenshot taken from the Julia extension settings.

---

<div class="post-metadata">

### Author: ![Soldalma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/soldalma/32/29388_2.png) [@Soldalma](https://discourse.julialang.org/u/Soldalma)
#### Post date: [December 18, 2021, 7:29pm UTC](https://discourse.julialang.org/t/why-does-vscode-say-there-is-a-problem-in-this-code/73280/10 "2021-12-18T19:29:23Z")

</div>

```julia
function df_select_col(df)
    select(df, :C)
end

```

does not generate messages in the `Problems` tab, but

```julia
function delete_col(df)
    select(df, Not(:Col))
end

```

generates

`Possible method call error. Julia[133, 16]`

I looked further into the linter. I can toggle it on or off in `settings.json` or equivalently with `Ctrl+Shift+P` and choosing `Julia: Toggle Linter`. When I toggle off the linter the messages on the `Problems` tab disappear.

I could not figure out how to get to the screen with `julia> Lint: Call` you posted. Typing `Lint: Call` or even just `Lint` on a `julia>` prompt generates an error message.

Thanks for the help.

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [December 19, 2021, 11:08am UTC](https://discourse.julialang.org/t/why-does-vscode-say-there-is-a-problem-in-this-code/73280/11 "2021-12-19T11:08:20Z")

</div>

Okay so it looks like the problem is then with `InvertedIndices` not being correctly picked up - does the error go away if you add that explicitly to your environment or use it?

I ran into a similar issue a few weeks ago here: [https://github.com/julia-vscode/julia-vscode/issues/2565](https://github.com/julia-vscode/julia-vscode/issues/2565)

The linter options are just in the regular Julia extension settings, so press `Ctrl+,` to open settings and then type `julia lint` to bring up all the Julia extension linter settings.

---

<div class="post-metadata">

### Author: ![Soldalma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/soldalma/32/29388_2.png) [@Soldalma](https://discourse.julialang.org/u/Soldalma)
#### Post date: [December 20, 2021, 11:18pm UTC](https://discourse.julialang.org/t/why-does-vscode-say-there-is-a-problem-in-this-code/73280/12 "2021-12-20T23:18:30Z")

</div>

I added `InvertedIndices` to the environment, restarted VSCode and the entry in the `Problems` tab is still there, whether I run the program from VSCode (clicking on an triangular arrow on the upper right of my screen) or by cutting and pasting in a REPL started from Powershell (inside VSCode) by typing `julia`.
