Jump to content

au3check false positive with "-w 3" and "-w 5"


Recommended Posts

Hi Guys

 

I am using au3check v3.3.13.19 and i came about some false positives when running the checks.

I have the setting "-w 1 -w 2 -w 3 -w 5 -w 6":

-w 3 gives me a false positive when doing the following:

 

$DEBUG_DB=True
...
If Not IsDeclared($DEBUG_DB) then Global $DEBUG_DB=False
...

Seems logic to me as the code is correct when running the program, but not to au3check. Is there anything i can do about this.

 

The next false-positive come when using -w 5

by DJKMan
Func _ArrayTo2DArray(ByRef $aArray, $Delimiter = @TAB, $Chunk_Size = 1000)
    If Not IsArray($aArray) Then Return SetError(1, 0, 0)

    ;ConsoleWrite("_ArrayTo2DArray() - Creating 2D Array...");Announce to the world you are creating something awesome
    Local $aFinal[1][1]
    Local $UBOUND_MAX = UBound($aArray) - 1;Store counts of how many array row elements there are in $aArray

    If $Chunk_Size < 1 Then $Chunk_Size = 1000;If User specifies a 0 or negative chunk size then set default



    Local $Final_Loop = False
    Local $Current_Row = 0
    Local $Start_Index = 0
    Local $CHUNK_SIZE_COUNTER = 0
    Local $aSplit[0]
    Local $Count=0

    If $UBOUND_MAX < $Chunk_Size Then
        ;Chunk size is larger than Ubound (only one loop needed)
        $Final_Loop = True
    EndIf

    ReDim $aFinal[UBound($aArray)][1];Resize to length of 1D beforehand to keep from performance hits

    While 1;Keep looping until max bound is reached

        For $Current_Index_Z = $Start_Index To UBound($aArray) - 1;Loop until it reaches EOF
            $CHUNK_SIZE_COUNTER += 1
            If $CHUNK_SIZE_COUNTER > $Chunk_Size Or $Current_Row > $UBOUND_MAX Then ExitLoop;If $Current_Index_Z reaches chunk size boundary then quit loop

            ;ConsoleWrite($Current_Index_Z & @CRLF);Uncomment to show how quickly it parses through the array..if it begins to slow down then choose a smaller chunk size

            $aSplit = StringSplit($aArray[$Current_Index_Z], $Delimiter, 3);Split on the delimiter
            
            If UBound($aFinal, 2) < UBound($aSplit) Then ReDim $aFinal[UBound($aFinal)][UBound($aSplit)];If there are more columns in text then create extra columns in array

            For $Current_Index_Y = 0 To UBound($aSplit) - 1
                $aFinal[$Current_Row][$Current_Index_Y] = $aSplit[$Current_Index_Y];Add all columns to array
            Next

            $Current_Row += 1;Keep track of current row of $aFinal since initialized array is full of blanks/also keep track of total progress
        Next
        $Start_Index = $Current_Row;Reset Start Index for next chunk size
        $CHUNK_SIZE_COUNTER = 0;Reset Chunk size tracker


        If $Final_Loop == True Then ExitLoop;Last chunk size parsed, reached end of array, exit loop

        If $Current_Row + $Chunk_Size < $UBOUND_MAX Then
            ;Continue looping through next large chunk
            ContinueLoop
            $Final_Loop = False
        Else
            ;Loop through the remaining elements smaller than or equal to the chunk size specified
            $Count = -1
            $Final_Loop = True
        EndIf
    WEnd

It complains about $Count not beeing used (" $Count = -1"). What is this about?

 

Best,

 

Thomas

 

Link to comment
Share on other sites

Regarding your first issue, you are using the syntax. IsDeclared() expects the name of the variable as a string not the actual variable.

 

$DEBUG_DB=True
If Not IsDeclared("DEBUG_DB") then Global $DEBUG_DB=False

 

  With the second issue au3check is correctly reporting that $Count is not used. You declare it and change it's value, but nowhere in your posted code do you use the value stored in $Count. Therefore the variable $Count can be completely removed with no effect on your code.

Edited by Bowmore

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...