Enhance Function Method Class Name Checking

Bug #1027413 reported by raphael shu
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
twistedchecker
Fix Released
Undecided
Unassigned

Bug Description

As there are many special names in Twisted,
the rule should be more flexible to cover these names, mainly:
1. Names like foo_BAR, foo_BAR_BAZ.
   ex. agentc_ADD_IDENTITY, cap_EXPIRE, cmd_NOT_FOUND.
2. Names begin with underscore, as they are special,
   we should not check them.
3. Names with specific patterns.
   ex. dictCode_221_ready, on_suspend_clicked, opt_mime_type.
   These patterns include:
   channel_,check_,dictCode_,dont_,do_,esmtpState_,get_,global_,handle_,
   inotify_,key_,on_,opt_,oscar_,packRequest_,parseRequest_,request_,
   smtpState_,state_,telnet_,testAddingBadProtos_,test_,view_,visitNode_,
   will_,wont_

Related branches

raphael shu (zomux)
summary: - Enhance Function Method Name Checking
+ Enhance Function Method Class Name Checking
Revision history for this message
Itamar Turner-Trauring (itamarst) wrote :

We had discussion last night about this on IRC. We decided the program should look for patterns like getattr(self, "request_%s" % x) as a way of figuring out which method names are legitimate.

Revision history for this message
raphael shu (zomux) wrote : Re: [Bug 1027413] Re: Enhance Function Method Class Name Checking

Im doing it in this way, and found this method of
automatically exception finding just works good,

and it found a list of exceptions below (in Twisted):

telnet_, sync_, _fromString_, auth_, perspective_, handleStatus_, Record_,
_parseSVNEntries_, get_, xmlrpc_, state_, iac_, macro_, handle_, start_,
_process_, ctcpReply_, parse_, dcc_, _toString_, observe_, func_, async_,
spew_, soap_, _stat_, convert_, channel_, ftp_, global_, packet_,
removeTrigger_, ext_, class_, opt_, do_, request_, render_, ssh_,
_unjelly_, response_, agentc_, cmd_, key_, ctcpQuery_, generate_, view_,
ssh_USERAUTH_PK_OK_, end_, oscar_, type_, irc_, search_, remote_,
linemode_, decode_, visitNode_a_, login_, visitNode_

anyway some exceptions not included in this list, and seems I could not
find any clue to find these patterns:

check_, dont_, esmtpState_, inotify_, inotify_, on_, packRequest_,
parseRequest_, smtpState_, testAddingBadProtos_, test_, will_, wont_,
testAlreadyCalledDebug_,
testAlreadyCalled_

Another problem is by this method, how could I determine whether a pattern
is for function name or class name?

Thanks.

On Sat, Aug 11, 2012 at 9:52 PM, Itamar Turner-Trauring <<email address hidden>
> wrote:

> We had discussion last night about this on IRC. We decided the program
> should look for patterns like getattr(self, "request_%s" % x) as a way
> of figuring out which method names are legitimate.
>
> --
> You received this bug notification because you are a member of
> TwistedChecker-Dev, which is subscribed to twistedchecker.
> https://bugs.launchpad.net/bugs/1027413
>
> Title:
> Enhance Function Method Class Name Checking
>
> Status in Twisted Coding Standard Checker:
> New
>
> Bug description:
> As there are many special names in Twisted,
> the rule should be more flexible to cover these names, mainly:
> 1. Names like foo_BAR, foo_BAR_BAZ.
> ex. agentc_ADD_IDENTITY, cap_EXPIRE, cmd_NOT_FOUND.
> 2. Names begin with underscore, as they are special,
> we should not check them.
> 3. Names with specific patterns.
> ex. dictCode_221_ready, on_suspend_clicked, opt_mime_type.
> These patterns include:
> channel_,check_,dictCode_,dont_,do_,esmtpState_,get_,global_,handle_,
> inotify_,key_,on_,opt_,oscar_,packRequest_,parseRequest_,request_,
> smtpState_,state_,telnet_,testAddingBadProtos_,test_,view_,visitNode_,
> will_,wont_
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/twistedchecker/+bug/1027413/+subscriptions
>

--
 *Raphael Shu , UACA 2012*

Revision history for this message
Itamar Turner-Trauring (itamarst) wrote :

1. Given it catches so many things, I suggest just going and doing it. It will reduce number of false positive dramatically. We can look into other cases separately, later (some of them are probably real problems that *should* be warnings).

2. You can tell it's for for method names because it's doing getattr on self. Class names that use a similar method are probably looked up using globals()['prefix_' + suffix] or something.

raphael shu (zomux)
Changed in twistedchecker:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.