You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ray Nicholus <rn...@widen.com> on 2012/06/08 17:32:20 UTC

FindBugs and the @Inject annotation on global fields

Is anyone using FindBugs in a T5 project?  If so, have you managed to find
a way to suppress the NPE warnings when dereferencing an injected field?
 This doesn't appear to be possible, which makes FB useless in a T5 app,
for the most part.  It's not clear that any other static analysis tools
provide such a filter either, though.  Anyone had luck with anything else?

Re: FindBugs and the @Inject annotation on global fields

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
What's a global field? As far as I know, Java has no such thing, just  
fields.

On Fri, 08 Jun 2012 12:32:20 -0300, Ray Nicholus <rn...@widen.com>  
wrote:

> Is anyone using FindBugs in a T5 project?  If so, have you managed to  
> find a way to suppress the NPE warnings when dereferencing an injected  
> field?

 From using the term 'dereferencing', I guess you've worked with C or C++  
for a long time. :P

-- 
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: FindBugs and the @Inject annotation on global fields

Posted by Ray Nicholus <rn...@widen.com>.
I'd hate to use such an annotation on every single instance.  Instead, I'd
love to filter out warnings based on annotation (in this case, Inject), but
FB doesn't allow this in their filter files.

On Fri, Jun 8, 2012 at 11:39 AM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Fri, 08 Jun 2012 13:20:24 -0300, Richard Frovarp <rf...@apache.org>
> wrote:
>
>  Which version of FindBugs are you using? I'm using FindBugs 1.x via Sonar
>> / Maven and I don't have any of those warnings being thrown. I've had to
>> get rid of a few of the rules regarding Unread field and Unused field as
>> @Property causes problems.
>>
>
> Isn't this the reason @SuppressWarnings("unused") exists? Doesn't FindBugs
> take this annotation into account? If not, I think it should.
>
> --
> Thiago H. de Paula Figueiredo
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: FindBugs and the @Inject annotation on global fields

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 08 Jun 2012 14:23:16 -0300, Richard Frovarp <rf...@apache.org>  
wrote:

> It can't. @SuppressWarnings has a RentionPolicy of SOURCE, so doesn't  
> survive past the compiler.

Thanks for the information. I haven't noticed it yet.

-- 
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: FindBugs and the @Inject annotation on global fields

Posted by Richard Frovarp <rf...@apache.org>.
On 06/08/2012 11:39 AM, Thiago H de Paula Figueiredo wrote:
> On Fri, 08 Jun 2012 13:20:24 -0300, Richard Frovarp
> <rf...@apache.org> wrote:
>
>> Which version of FindBugs are you using? I'm using FindBugs 1.x via
>> Sonar / Maven and I don't have any of those warnings being thrown.
>> I've had to get rid of a few of the rules regarding Unread field and
>> Unused field as @Property causes problems.
>
> Isn't this the reason @SuppressWarnings("unused") exists? Doesn't
> FindBugs take this annotation into account? If not, I think it should.
>

It can't. @SuppressWarnings has a RentionPolicy of SOURCE, so doesn't 
survive past the compiler. Since FindBugs looks at the byte code, it's 
gone by that point. FindBugs has their own annotation, but I don't want 
to use that. We're still finding such variables, but it's via PMD I think.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: FindBugs and the @Inject annotation on global fields

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 08 Jun 2012 13:20:24 -0300, Richard Frovarp <rf...@apache.org>  
wrote:

> Which version of FindBugs are you using? I'm using FindBugs 1.x via  
> Sonar / Maven and I don't have any of those warnings being thrown. I've  
> had to get rid of a few of the rules regarding Unread field and Unused  
> field as @Property causes problems.

Isn't this the reason @SuppressWarnings("unused") exists? Doesn't FindBugs  
take this annotation into account? If not, I think it should.

-- 
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: FindBugs and the @Inject annotation on global fields

Posted by Richard Frovarp <rf...@apache.org>.
On 06/08/2012 10:32 AM, Ray Nicholus wrote:
> Is anyone using FindBugs in a T5 project?  If so, have you managed to find
> a way to suppress the NPE warnings when dereferencing an injected field?
>   This doesn't appear to be possible, which makes FB useless in a T5 app,
> for the most part.  It's not clear that any other static analysis tools
> provide such a filter either, though.  Anyone had luck with anything else?
>

Which version of FindBugs are you using? I'm using FindBugs 1.x via 
Sonar / Maven and I don't have any of those warnings being thrown. I've 
had to get rid of a few of the rules regarding Unread field and Unused 
field as @Property causes problems.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: FindBugs and the @Inject annotation on global fields

Posted by Martin Strand <do...@gmail.com>.
I use constructor injection for all services, so Findbugs works as expected there.
But I've had to disable Findbugs for page/component classes since there is so much magic going on there.

On Fri, 08 Jun 2012 17:32:20 +0200, Ray Nicholus <rn...@widen.com> wrote:

> Is anyone using FindBugs in a T5 project?  If so, have you managed to find
> a way to suppress the NPE warnings when dereferencing an injected field?
>  This doesn't appear to be possible, which makes FB useless in a T5 app,
> for the most part.  It's not clear that any other static analysis tools
> provide such a filter either, though.  Anyone had luck with anything else?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: FindBugs and the @Inject annotation on global fields

Posted by Ray Nicholus <rn...@widen.com>.
The filter files do not allow you to filter by annotation.

On Fri, Jun 8, 2012 at 11:11 AM, Lance Java <la...@googlemail.com>wrote:

> Not really a tapestry question but I'm in a good mood ;)
>
> The findbugs maven plugin accepts an "excludeFilterFile" configuration
> parameter. This file can contain rules that you wish to exclude from the
> findbugs report.
>
> http://mojo.codehaus.org/findbugs-maven-plugin/usage.html
> http://findbugs.sourceforge.net/manual/filter.html
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/FindBugs-and-the-Inject-annotation-on-global-fields-tp5713724p5713727.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: FindBugs and the @Inject annotation on global fields

Posted by Lance Java <la...@googlemail.com>.
Not really a tapestry question but I'm in a good mood ;)

The findbugs maven plugin accepts an "excludeFilterFile" configuration
parameter. This file can contain rules that you wish to exclude from the
findbugs report.

http://mojo.codehaus.org/findbugs-maven-plugin/usage.html
http://findbugs.sourceforge.net/manual/filter.html

--
View this message in context: http://tapestry.1045711.n5.nabble.com/FindBugs-and-the-Inject-annotation-on-global-fields-tp5713724p5713727.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org