Re: rules for properties declared in headers

92 views
Skip to first unread message

Longyi Qi

unread,
Jul 24, 2013, 8:25:54 PM7/24/13
to Jan Berkel, oclin...@googlegroups.com
Hi Jan,
Thank you for working on the rule and bringing this up again for attention.

This is currently a limitation of oclint. 

It happens at file https://github.com/oclint/oclint/blob/master/oclint-rules/include/oclint/AbstractASTVisitorRule.h line 25, where we filter out the AST nodes that do not reside in the current file. Header files and pre-compiled files are then filtered out on this line.

Removing that condition would get the rules applied to all code.

However, there are two side effects of doing so -
1. Since all nodes are applied, the analysis time would take longer. 
2. Without filtering headers, all headers will be analyzed then, this includes framework headers, library headers, and system headers. This currently could result in a large amount of false positives, and there might be violations that are totally irrelevant to the file being analyzed. For this, a practical approach is to write a post-processing script, which takes the oclint report, and extract only files of interests, e.g. `grep` for text report.

If you have any suggestions, we sincerely would like to hear from you. Thank you in advance.

Regards,
Longyi











On Wed, Jul 24, 2013 at 4:28 PM, Jan Berkel <jan.b...@gmail.com> wrote:
Hi,

i added a new rule to enforce certain attributes on ObjectiveC properties (https://github.com/jberkel/oclint/commit/35a1e15c4188e46dbb7ab1d9aaa8a7f150cc2b5b). However it looks like VisitObjCPropertyDecl is only called for properties declared in implementation (.m) files, not for actual headers where it would be more useful.

Is this a limitation of oclint / clang or is there a trick to get rules applied to code in header files?

 Jan

--
You received this message because you are subscribed to the Google Groups "OCLint Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to oclint-users...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Joris Dauphin

unread,
Jul 25, 2013, 12:21:02 PM7/25/13
to oclin...@googlegroups.com, Jan Berkel
An other way is to tell to oclint to parse header file directly (this method currently works).

-- 8< --
oclint *.m *.cpp *.c *.h -- 
-- >8 --

The problem is that headers don't appear in the database compile_commands.json
So we don't know which compile flags to use :-/

Jan Berkel

unread,
Jul 25, 2013, 6:46:10 PM7/25/13
to oclin...@googlegroups.com
On Thu, Jul 25, 2013 at 6:21 PM, Joris Dauphin <joris....@gmail.com> wrote:
An other way is to tell to oclint to parse header file directly (this method currently works).

-- 8< --
oclint *.m *.cpp *.c *.h -- 
-- >8 --


thanks for your replies, this is the first thing i tried, but unfortunately it didn't work.
i'll see if i can create a test case for it. 

Longyi Qi

unread,
Jul 29, 2013, 7:29:13 PM7/29/13
to Jan Berkel, oclin...@googlegroups.com
This should work, say you create a `foo.h` file with content

```
int m()
{
    int i;
    return 0;
}
```

And when you run `/path/to/oclint-release/bin/oclint foo.h -- -c`, it should returns something like

```
OCLint Report

Summary: TotalFiles=1 FilesWithViolations=1 P1=0 P2=0 P3=2 

/home/lqi/Playground/oclint/foo.h:3:5: unused local variable P3 
/home/lqi/Playground/oclint/foo.h:3:5: short variable name P3 Variable name with 1 characters is shorter than the threshold of 3

[OCLint (http://oclint.org) v0.8dev]
```

Let us know if you get it to work.

Thanks,
Longyi






--
You received this message because you are subscribed to the Google Groups "OCLint Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to oclint-dev+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages