include & exclude in code inspections

We're working on a rather big project containing 3 modules. My team's only writing code in 3 different subdirectories of one module, so I don't want to inspect the other modules nor the other subdirs, so I started using the '-Didea.include.patterns=' and '-Didea.exclude.patterns'.

Because I did read somewhere that includes had precedence over excludes I used:
-Didea.exclude.patterns=[common]/*;/;/* -Didea.include.patterns=[web]/source/com/foo/bar/util/*;/source/com/foo/taglibs/;/source/com/foo/model/*

Nothing was included, so I removed /** from the exclude patterns. The result was that teamcity now inspected /source/com/foo/bar/** (note that I only asked for the util subdir here).

Now I've set up three different build configurations, each including only one pattern and I'm getting too many inspection results (always some additional packages above the directory I specify). This is only a workaround, I hope I'm misconfiguring something or that there is a fix in a future release. Could someone help me out?

4 comments

Hello Peter,

There is a bug. You may want to watch/vote for it http://jetbrains.net/jira/browse/IDEADEV-24516

If you exclude smth then all that content will be excluded forever. So the
right pattern is
-Didea.exclude.patterns=[common]/*;/* -Didea.include.patterns=[web]/source/com/foo/bar/util/*;/source/com/foo/taglibs/;/source/com/foo/model/*

Thank you

-


Anna Kozlova
JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

We're working on a rather big project containing 3 modules. My team's
only writing code in 3 different subdirectories of one module, so I
don't want to inspect the other modules nor the other subdirs, so I
started using the '-Didea.include.patterns=' and
'-Didea.exclude.patterns'.

Because I did read somewhere that includes had precedence over
excludes I used:

-Didea.exclude.patterns=[common]/*;/;/*
-Didea.include.patterns=[web]/source/com/foo/bar/util/**;[web]/source/
com/foo/taglibs/*;/source/com/foo/model/*

Nothing was included, so I removed /** from the exclude patterns.
The result was that teamcity now inspected /source/com/foo/bar/**
(note that I only asked for the util subdir here).

Now I've set up three different build configurations, each including
only one pattern and I'm getting too many inspection results (always
some additional packages above the directory I specify). This is only
a workaround, I hope I'm misconfiguring something or that there is a
fix in a future release. Could someone help me out?



0

Anna, thanks for fixing this first bug.

A second problem is that when using the pattern you specify, TeamCity seems to take into account only one of the include patterns given. I don't understand how and why it chooses one of the three includes given, but one is included and the other two are ignored.

The third problem I have is that if I use '-Didea.exclude.patterns=[common]/*;/* -Didea.include.patterns=[web]/source/com/foo/bar/util/*', it will act as if I wrote (ant-style) include="/web/source/com/foo/bar/.java;/web/source/com/foo/bar/util/**".

Thanks for looking at these as well,
Peter

Hello Peter,

There is a bug. You may want to watch/vote for it
http://jetbrains.net/jira/browse/IDEADEV-24516
If you exclude smth then all that content will be
excluded forever. So the
right pattern is
-Didea.exclude.patterns=[common]/*;/*
-Didea.include.patterns=[web]/source/com/foo/bar/util/**;
/source/com/foo/taglibs/*;/source/com/foo/model/*

Thank you

---------------------
Anna Kozlova
JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

>

0

Hello Peter,

I hope that I've already fixed the second problem: the first include pattern
excluded all siblings if they are not explicitly included - which is wrong
in your case.

I am afraid that I am unable to resolve your third problem :( IDEA can exclude
only folders. All other cases are unsupported.

Seems that nethertheless I've got a solution.

Exclude/include patterns should be used in order to reduce computations.
If you exclude via exclude patterns Unused Declaration inspection will report
everything as unused because exclude pattern works as exclude folder in UI
and find usages etc will ignore everything under that folders.

If you use IDEA as your IDE the better solution is to setup inspection profiles
per project: you can set up your scope and define a profile on it + define
a complementary scope and an empty profile on it. After that IDEA will report
only problems for your scope and ignore all files in complementary scope.
But you still will be able to retrieve "usage" information from complementary
scope.

Is it ok for you?

Thank you

-


Anna Kozlova
JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

P.S. Project Profiles mapping is difined on: File|Settings|Errors|Project
Profiles

Anna, thanks for fixing this first bug.

A second problem is that when using the pattern you specify, TeamCity
seems to take into account only one of the include patterns given. I
don't understand how and why it chooses one of the three includes
given, but one is included and the other two are ignored.

The third problem I have is that if I use
'-Didea.exclude.patterns=[common]/*;/*
-Didea.include.patterns=[web]/source/com/foo/bar/util/**', it will act
as if I wrote (ant-style)
include="/web/source/com/foo/bar/.java;/web/source/com/foo/bar/util/
*".

Thanks for looking at these as well,
Peter

>> Hello Peter,
>>
>> There is a bug. You may want to watch/vote for it
>> http://jetbrains.net/jira/browse/IDEADEV-24516
>> If you exclude smth then all that content will be
>> excluded forever. So the
>> right pattern is
>> -Didea.exclude.patterns=[common]/*;/*
>> -Didea.include.patterns=[web]/source/com/foo/bar/util/**;
>> /source/com/foo/taglibs/*;/source/com/foo/model/*
>> Thank you
>>
>> -


>> Anna Kozlova
>> JetBrains Inc.
>> http://www.intellij.com
>> "Develop with pleasure!"


0

I'll try to rephrase my third problem:
When specifying -Didea.include.patterns=[web]/source/com/foo/bar/_util_/**, I guess TeamCity sees '..' as a directory as well and in fact includes files coming from com/foo/bar too. This is annoying, but not a big deal.

Thanks for your hint to configure all of this in IDEA. I'll give it a try.
Peter

0

Please sign in to leave a comment.