Questions tagged [unused-variables]

Use this tag when question related to unused variables issues as warnings

179 questions
-1
votes
1 answer

Unused variable outside of a for-loop in Go

I can't compile the following Go code. I keep getting an error that variable 'header' is not used. I'm trying to read and process a CSV file. The file is read line by line an so I need to save the header into a "outside-the-loop" variable I can…
michal-ko
  • 397
  • 4
  • 12
-1
votes
1 answer

How to find unused variables in a Makefile

I'm maintaining a Makefile for a project, which contains many variable declarations: DOCKER_IMAGE_VERSION := latest DOCKER_EXPOSE_PORT := 8080 PIP := python -m pip ... Sometimes the lines using these variables are deleted, and these declarations…
Adam Matan
  • 128,757
  • 147
  • 397
  • 562
-1
votes
1 answer

Values in if-else

I have directions for a programming assignment that says, all within a conditional, I need to prompt the user 7 times for their scores [hi,med,low]. I need to be able to use these values later so naturally I assigned them all to a value to be able…
-1
votes
2 answers

How can I discard both of an argument and a local variable in the same scope?

My current code seems like this: // for given methods like these: // void Foo(Action action) // async Task DoAsync() Foo(unusedInt => { var unusedTask = DoAsync(); }); I know I can use the discard variable(_) since C#7.0, like this: Foo(_…
ALittleDiff
  • 1,191
  • 1
  • 7
  • 24
-1
votes
1 answer

error: unused variable (struct)

error: unused variable 'part2' [-Werror,-Wunused-variable] The error occurs only for part2 even though it's been initialized as well, just in a different manner. Is it just a compiler issue ? int main(void) { struct complex { int…
callmeanythingyouwant
  • 1,789
  • 4
  • 15
  • 40
-1
votes
2 answers

Getting errors of "unused variable" and "undeclared identifier" in simple function I am trying to write in C and I can't understand why

So I am writing a cipher program as part of the Harvard CS50 course and I have this code to check if a character + the cipher key will put it out of ASCII alphabetical range and to loop it back around if it does (as well as preserving case). The…
-1
votes
1 answer

Warning: Wunused-but-set-variable

I receive this warning when compiling my program. In member function 'bool CClientManager::InitializeMobTable()': warning: variable 'isNameFile' set but not used [-Wunused-but-set-variable] bool isNameFile = true; ^ Here is the relevant part…
Freaksy
  • 41
  • 1
  • 4
-1
votes
2 answers

"Unused variable" in xcode

I receive the error "Unused variable 'placesList'" when I write the following: PlacesList *placesList = [[PlacesList alloc] initWithNibName:@"PlacesList" bundle:nil]; What am I doing wrong? How can I fix it? I am new and inexperienced with coding…
Luke Curran
  • 77
  • 10
-2
votes
1 answer

Go believes variables inside conditional statements are unused?

I have a situation where if something fails to assign a variable I instead assign it within a conditional statement however Go seems to think this variable is unused. for index, value := range group.Values { timestamp, err :=…
Grant Curell
  • 1,321
  • 2
  • 16
  • 32
-2
votes
1 answer

Unused local variable false positive

While using sonar lint version 6.3.0.39716, it reports the following variable as unused. void read() throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String s; // unused local…
BeastMaster64
  • 147
  • 1
  • 13
-2
votes
2 answers

How to prevent getting warning of unused variable implementation of an abstract class

I have an abstract class which has an event (abstract). I do not need actually this event in my implementation. When I dont use it in my implementation, it gives well warning, which I dont want to have.. Is there any c# predefine annotation like…
Wolfgang
  • 91
  • 6
-2
votes
3 answers

statement with no effect for-loop C

I got this for-loop: for(int k=4;k<0;k--){ if(k == 0){ test[k] = 5; break; } else{ test[k] = test[k-1]; } } it should shift the elements of the array to the right, but nothing happens. To my knowledge it…
Tomas0206
  • 77
  • 1
  • 7
-3
votes
0 answers

vscode is broken with unity

enter image description here Can someone explain it to me ? what is happening here there is no parameter in that method and the unity specific methods are also shown as unused by the analyzer i did not make any update and such and i did try…
-3
votes
1 answer

Detect and flag unused JS variables

I'm currently using JSHint and JSCS (javascript code style checker) but none of them can detect this kind of unused variables: describe('XX', function () { var XXunused; beforeEach(inject(function ($injector) { XXunused =…
ernestoalejo
  • 853
  • 1
  • 12
  • 23
1 2 3
11
12