Ticket #279 (assigned enhancement)
Warn about unused method's argument
Reported by: | maboiteaspam | Owned by: | Charles |
---|---|---|---|
Priority: | trivial | Milestone: | |
Component: | Cobra Compiler | Version: | 0.8.0 |
Keywords: | Cc: |
Description
Detect unused method arguments within his body
Define a new arg modifier that is allowing to declare unused parameter
class Example def looks_like_a_mistake( param ) print 'Hello world ! i did not use provided argument' # must print a warning def looks_like_ok( param as unused String ) print 'Hello world ! i did not use provided argument' # is ok, as arg in declared unused def is_also_ok_as_abstract( ) is abstract # is ok as method this is an abstract method def passed_method_are_also_ok( ) pass # this is ok as there is only one statement, and this is a PassStmt
The warning should read:
The value of parameter "[param.name]" is never used in [.parentBox.name].[.name]. #BackEndObjC/ObjcGenerator.cobra(247): warning: The value of parameter "cw" is never used in SomeClass.SomeMethod.
Concerning current patch
- Provided patch does skip abstract method, empty method, pass'ed method,
- They are some unexpected result when logging operations, i don't really know what it is for now
: (empty)(1): warning: The value of parameter "value" is never used in IExpr.type.set. : (empty)(1): warning: The value of parameter "value" is never used in IExpr.receiverType.set. : (empty)(1): warning: The value of parameter "value" is never used in IExpr.contextType.set
- I found what looks like a false/positive in
: Source/Cobra.Lang/CobraFrame.cobra(13): warning: The value of parameter "args" is never used in ['public'] CobraFrame.cue.init.
where code source is like this
namespace Cobra.Lang class CobraFrame implements HasAppendNonPropertyKeyValues .... var _args as Object[] .... cue init(declClassName as String, methodName as String, fileName as String, lineNum as int, args as vari Object) """ args should have the arg names embedded: "x", x, "y", y """ .... _args = sharp'(object[])args.Clone()' .... get args from var #...
- For now there is 123 parameters detected as unused, they was 300 at beginning.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.