Jump to content

Au3Check.exe


tylo
 Share

Recommended Posts

It shouldn't be a necessary for all library code to pass all warning test, IMO. For example where Eval() is used (e.g in ArrayCreate), you'll have to make dummy code (as Valik showed) to avoid them. A warnings flags that there may be a logical error or unclean code, but it may also be perfectly correct code.

I am of the mindset that all warnings are errors. None of my code ever has warnings in it. With C++, I generally don't just hide them warnings with pragma, either, I fix them. I don't think it's unreasonable that the standard library code should pass all warnings. How would you feel if the C standard library or C++ standard library threw dozens of warnings when you tried to use them? All the spurious warnings that aren't even in your code are going to hide the problems that are in your code. Writing work-arounds like what I showed is harmless. The code appears after the last Return statement in the function so the code imposes no runtime performance penalty from all the assignments. And for the record, that simple little fix suppressed around 100 lines of warning text.

If the standard library can't appeal to both people who don't write clean code to those who are very pedantic about their code such as myself, then the standard library has failed.

The other concern is how to utilize the produced lists to remove unused code. When I add file and line reference to definitions of the symbols, it should be easy to exclude non-used functions by simply cutting the lines where these are defined. However, global variables are more tricky. Valik's concerns with unused vars initialized with a function, put me on the track. E.g. in

Global $g_app, $g_status = MyInit()
$g_status may not be used by any code, but MyInit() must for sure be called, so you cannot simply remove the line. That would also falsely remove the $g_app declaration. In any case, when multiple variables are declared on the same line, the line probably must be batch edited to remove certain declarations.
Exactly! That's what I meant by function calls might have side effects so warning about unused variables being assigned via function calls is bad.
Link to comment
Share on other sites

  • Developers

Any plans for SciTE to have a GUI AU3Check Config (something like the SciTE Config) so that Au3Check options can be turned off and on at will?

Or do you think that may lead to an increase in false bug reports because noobs (like me) have used the wrong options?

No plans yet but could be done easily thru the CompileAU3 process we have. Either by means of a Compiler directive or using the CompileAu3.INI file.

I will have a look at this soon......

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

au3check v1.51:

  • fixed: unused global variables was not in the list
  • added: file and position reference to all symbols when using -u or -U. You may use dash - to output to stdout.
  • "unused" global variables that are initialized with a function-expr are now in the used list (-u)
  • reverted to -w 5 as in v1.49. -w 6 is now warn on Dim.
  • added: new directive: #uses follwed by a comma separated list of function and/or variable names. It serves two purposes:
  • to prevent unused local vars warnings (-w 5)
  • to force inclusion of symbols in the used list (-u)
Maybe it would be better with only one symbol list which had marked used/unused, and sorted by file/pos/symbol. There are additionally a few issues I want to discuss on this. Later.

Cheers.

Edited by tylo

blub

Link to comment
Share on other sites

v1.52 released.

Ok, not much response on 1.51, but v1.52 produces a very easy to use list of unreferenced functions and variables. For various reasons, the -u option, which produced a list of referenced symbols, is no longer available because it is inaccurate. -U now produces a list of line segments that can be removed, e.g

C:\Program Files\AutoIt3\Include\Array.au3(115,1) : (153):  _ArrayDelete

It means that the code in lines 115-153 in Array.au3 can be removed from a compiled script.

For variables, a pragmatic approach is used. It only lists explicitly declared global variables that are not referenced later. If many variables are declared on one line, only the first variable is listed - if none of the variables are referenced. e.g.

21: Global $var1, $var2 = 1, _
22:     $var3

lists only the first variable if none of the variables are referenced later. Line 21-22 is output for removal:

C:\test\test.au3(21,1) : (22):  $var1

This approach is required for Enums BTW, because if one enum value is referenced, the whole group of enums should be concidered referenced. (taking away one, changes the value of the subsequent enums).

Note also that a declared global variable which is initialized with a function or an expression containing a function is concidered referenced. This is because the function may have side effects and therefore the line should not be removed (even though the declared variable is never referenced later).

The directive #uses introduced in 1.51 is now renamed to #forceref, as jpm specified. Again it has two purposes, one is to avoid -w 5 warnings:

Func _ArrayCreate($v_0, $v_1 = 0, $v_2 = 0, $v_3 = 0, $v_4 = 0, $v_5 = 0, $v_6 = 0, $v_7 = 0, $v_8 = 0, $v_9 = 0, $v_10 = 0, $v_11 = 0, $v_12 = 0, $v_13 = 0, $v_14 = 0, $v_15 = 0, $v_16 = 0, $v_17 = 0, $v_18 = 0, $v_19 = 0, $v_20 = 0)
    #forceref $v_0, $v_1, $v_2, $v_3, $v_4, $v_5, $v_6, $v_7, $v_8, $v_9, $v_10, $v_11, $v_12, $v_13, $v_14, $v_15, $v_16, $v_17, $v_18, $v_19, $v_20
    Local $i_UBound = @NumParams
    Local $av_Array[$i_UBound]
    Local $i_Index

    For $i_Index = 0 To ($i_UBound - 1)
        $av_Array[$i_Index] = Eval("v_" & String($i_Index))
    Next
    Return $av_Array
EndFunc  ;==>_ArrayCreate

The other purpose of #forceref is to avoid global variables and functions to appear in the unreference symbols list, e.g. if called via Call($fn).

Note 1: you can use -U - to output unreference symbols to stdout.

Note 2: au3check.dat must contain a line with: "*COM_EventObj" in order to accept the macro @COM_EventObj used as a COM object. Please check the .dat file.

blub

Link to comment
Share on other sites

Note 2: au3check.dat must contain a line with: "*COM_EventObj" in order to accept the macro @COM_EventObj used as a COM object. Please check the .dat file.

JdeB, if you haven't already, just add *COM_EventObj to the "Additions" key in the Ini file of my script that generates Au3Check.dat.
Link to comment
Share on other sites

  • Developers

JdeB, if you haven't already, just add *COM_EventObj to the "Additions" key in the Ini file of my script that generates Au3Check.dat.

Will do... Thanks

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • 3 weeks later...

Tylo,

Apologies if this has been covered...

I'm using v1.52 with 'w' switches 1 through to 6.

In a script containing the snippet below, the '-w 5' switch is giving

'WARNING: $MyWindow: declared, but not used in func.'

Func _MyMsgBox($title, $Text, $Timeout = 0)
Local $MyWindow, $ReadOnly_Edit, $Btn_Exit, $tBegin, $Msg
Local $i, $j, $MsgText
    
If IsArray($Text) Then
; Only supports 1 or 2d arrays
    If UBound($Text, 0) = 1 Then
            For $i = 0 To UBound($Text) - 1
                $MsgText = $MsgText & $Text[$i] & @CRLF
            Next
        ElseIf UBound($Text, 0) = 2 Then
            For $i = 0 To UBound($Text) - 1
                For $j = 0 To UBound($Text, 2) - 1
                    $MsgText = $MsgText & $Text[$i][$j] & ";"
                Next
                $MsgText = StringTrimRight($MsgText, 1) & @CRLF
            Next
        Else
        ; Not supprted
            $MsgText = "Array with more than 2 dimensions: not supported."
        EndIf
    Else
        $MsgText = $Text
    EndIf
    
    $MyWindow = GUICreate($title, $WindowWidth, $WindowHeight + $Margin, $WindowX, $WindowY, $WS_OVERLAPPEDWINDOW)
    ...etc

$MyWindow is not used nor declared anywhere else in the script.

The same problem occurs in the same script, different function & var.

I'd be grateful for any advice.

Cheers,

Pete

Link to comment
Share on other sites

  • Developers

'WARNING: $MyWindow: declared, but not used in func.'

-snip-

$MyWindow is not used nor declared anywhere else in the script.

The same problem occurs in the same script, different function & var.

If you are not using $MyWindow anywhere else in the function, then this warning is correct.

It means you only set the value but never use it .

Just remove the $MyWindow totally:

GUICreate($title, $WindowWidth, $WindowHeight + $Margin, $WindowX, $WindowY, $WS_OVERLAPPEDWINDOW)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I created a dll with the "au3_plugin_sdk".

When compiling the script au3check gives an error:

C:\Temp\dll.au3(2,14) : ERROR: myfunc(): undefined function.

myfunc("Parm")

~~~~~~~~~~~~~^

C:\Temp\dll.au3 - 1 error(s), 0 warning(s)

How can I avoid error messages on the external functions in a dll like this:

$hDll = PluginOpen("my.dll")
myfunc("Parm")
PluginClose($hDll)

#forceref myfunc

doesn't work and

#forceref myfunc()

gives an error in the '('

Is there a way to define these functions as external?

Link to comment
Share on other sites

I created a dll with the "au3_plugin_sdk".

When compiling the script au3check gives an error:

C:\Temp\dll.au3(2,14) : ERROR: myfunc(): undefined function.

myfunc("Parm")

~~~~~~~~~~~~~^

C:\Temp\dll.au3 - 1 error(s), 0 warning(s)

How can I avoid error messages on the external functions in a dll like this:

$hDll = PluginOpen("my.dll")
myfunc("Parm")
PluginClose($hDll)

#forceref myfunc

doesn't work and

#forceref myfunc()

gives an error in the '('

Is there a way to define these functions as external?

If i remember correctly

#Compiler_PlugIn_Funcs=myfunc

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

  • Developers

#Compiler_PlugIn_Funcs=myfunc

One thing to remember is that this is a function of the CompileAU3 utility which is used as a wrapper for Au3check,Autoit3 and aut2exe. It will temporarily add the functions defined in the Compiler directive to the Au3Check.dat definitions file.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

#Compiler_PlugIn_Funcs=myfunc

One thing to remember is that this is a function of the CompileAU3 utility which is used as a wrapper for Au3check,Autoit3 and aut2exe. It will temporarily add the functions defined in the Compiler directive to the Au3Check.dat definitions file.

Thanks. I always use the complete compile sequence from Scite. The popup window with the error messages became annoying and I was afraid that a real error would slip through.

It took some time to find out that there are no spaces allowed when separating function names with comma's.

(#Compiler_PlugIn_Funcs=myfunc1,myfunc2) is Ok

(#Compiler_PlugIn_Funcs=myfunc1, myfunc2) will ignore myfunc2.

But that's is no problem.

Everything now compiles fine. Thanks again.

Dick

Link to comment
Share on other sites

  • Developers

Thanks. I always use the complete compile sequence from Scite. The popup window with the error messages became annoying and I was afraid that a real error would slip through.

It took some time to find out that there are no spaces allowed when separating function names with comma's.

(#Compiler_PlugIn_Funcs=myfunc1,myfunc2) is Ok

(#Compiler_PlugIn_Funcs=myfunc1, myfunc2) will ignore myfunc2.

But that's is no problem.

Everything now compiles fine. Thanks again.

Dick

Will fix that in the next version of Compileau3 so that leading and trailing spaces are stripped .... :o

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Will fix that in the next version of Compileau3 so that leading and trailing spaces are stripped .... :o

You won't have to...

Au3Check v1.54:

- added: Support for #compiler_plugin_funcs=<func-list> directive.

- replaced: -U option with -v 3. Output format is a little changed.

JdeB: I wanted native support for this directive so it works outside of Scite too. The native support won't conflict with the external support you made, but you can remove it in next Scite release.

blub

Link to comment
Share on other sites

You won't have to...

Au3Check v1.54:

- added: Support for #compiler_plugin_funcs=<func-list> directive.

- replaced: -U option with -v 3. Output format is a little changed.

JdeB: I wanted native support for this directive so it works outside of Scite too. The native support won't conflict with the external support you made, but you can remove it in next Scite release.

I think I send you some slight modification to have the .exe with a version. At least it was my intention just see the upload area :o
Link to comment
Share on other sites

tylo, why don't you just find the plugin DLL and read it's exported functions like AutoIt rather than force users to hard-code the functions in?

I guess that would be nice. However it's a little work involved (even if I use code from autoit). On the other hand, "declaring" functions to be used from a plugin dll is nice documentation of where the function is coming from. e.g.
$hDll = PluginOpen("my.dll")
#Compiler_PlugIn_Funcs=myfunc
...
myfunc("Parm")
...
PluginClose($hDll)

@jpm: I'll look at it - thanks.

blub

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...