TeamCity IntelliJ Inspections - Include Files in Inspection Scope - intellij-idea

Question: How can I get TeamCity to run inspections against the 3 html files in the www root directory?
I'm working on a node.js project. The team are all using JetBrains IDEA based IDEs. We have shared our Inspection Profile and a Scope for them to run against.
We have just setup TeamCity and have a build configuration to run the Inspections. It is working identically for everything except the 3 html files directly under the "www" directory. The problem is that errors for those 3 files are reported in IntelliJ but not in TeamCity.
The only thing that appears to be different is the scope. IntelliJ uses scope defined in an xml file. TeamCity scope is set through the UI (build step form field "Include / exclude patterns"). TeamCity's scope syntax is different to IntelliJ's ...for the life of me I cannot get TeamCity to operate on the same scope!
Intended Scope
Here is a picture of the Project with the inspection scope underlined in green. We want to exclude libraries and the very root folder of config, but include everything else (i.e. everything we write).
TeamCity Scope
I have tried 2 strategies and both seem to work in IntelliJ and fail on TeamCity.
Attempt 1 - Include Only:
+:backend/**
+:tests/**
+:www/css/**
+:www/dist/**
+:www/images/**
+:www/*
Attempt 2 - Include entire www then Exclude:
+:backend/**
+:tests/**
+:www/**
-:www/components/**
-:www/components-unmanaged/**
-:www/data/**
-:www/images/**
IntelliJ Scope
In IntelliJ both work.
Attempt 1 - Include Only:
pattern="file:backend//*||file:tests//*||file:www/css//*||file:www/dist//*||file:www/images//*||file:www/index.html||file:www/loadsave.html||file:www/logical.html"
...more readable with some line breaks:
file:backend//*
||file:tests//*
||file:www/css//*
||file:www/dist//*
||file:www/images//*
||file:www/index.html
||file:www/loadsave.html
||file:www/logical.html
Attempt 2 - Include entire www then Exclude:
(file:backend//*||file:tests//*||file:www//*)&&!file:www/components//*&&!file:www/components-unmanaged//*&&!file:www/data//*&&!file:www/images//
...again, more readable with line breaks:
(
file:backend//*
||file:tests//*
||file:www//*
)
&&!file:www/components//*
&&!file:www/components-unmanaged//*
&&!file:www/data//*
&&!file:www/images//
References
https://confluence.jetbrains.com/display/TCD9/Inspections#Inspections-IdeaPatterns
the pattern must satisfy the following rules: must end with either **
or * (this effectively limits the patterns to only the directories
level, they do not support file-level patterns);
...
the include pattern has a special behavior (due to underlying
limitations): it includes the directory specified and all the files
residing directly in the directories above the one specified.
Other Thoughts: Differing Inspection Support
The only other thought I had was that perhaps TeamCity just plain doesn't support the HTML inspections category that IntelliJ does, or so some bizarre reason it refuses to assess .html files.
Software Versions
IntelliJ IDEA 2016.1.2 (Build #IU-145.972, built on May 14, 2016)
TeamCity Professional 9.1.7 (build 37573)

Related

exclude folder and file patterns for java compiler in idea intellij

I recently migrated from eclipse to intellij. I have many folders and files to be excluded from compilation. Eg. I have about 40-50 folders named 'test' containing class files and folders that needs to be excluded. I also need to exclude any class file whose name ends with *Test.java.
In eclipse the exclusion pattern is - **/test/** and **/*Test.java that I could set at project level.
In Intellij, I cannot find any equivalent thing that works. It is impractical for me to manually add 100s of folders and files individually at - 'Settings -> Build, Execution, Deployment -> Compiler -> Excludes'.
Does Intellij support exclusion pattern for folders and file like eclipse? Can you help me with above example - on what is the pattern and where to set it in intellij?
Please do not ask me to individually add all the test folders and files ending with Test.java to exclude. There are 100s of them. Looking for regex pattern like in eclipse.
Thanks.

How to mark a directory as a generated-test-source root in IntelliJ?

I'm trying out Dagger2 in Intellij 2016.1 (but not with gradle) on ubuntu.
Intellij creates dagger's generated sources in either
./out/production/<ProjectModule>/generated/ or
./out/test/<ProjectModule>/generated_tests/ depending on if it was generated from a source or test directory, respectively.
But from what I tell, I can only mark those directories as either sources root, test sources root, or generated sources root; there is no option for generated test sources root, say.
Why is this important? Because the generated test sources depend on my test sources. If they are marked as a generated sources root then Intellij cannot find the dependencies.
Note: I don't think they should be marked as test sources root because then Intellij tries to compile those again; unless there is some way of preventing this of which I am unaware.
So is there a way to mark this directory as a generated test sources root or something equivalent?
To mark a diectory as "generated test sources root", open the "Project Structure" dialog at Project Settings > Modules and click on the little "P" next to your folder of choice, and select the "For generated resources" button.
Dagger uses annotation processing to generate sources during compilation. IntelliJ has a specific configuration for this feature in Settings -> Build, Execution, Deployment -> Compiler -> Annotation Processors
When it is enabled IntelliJ automatically adds generated sources to project.
With annotation processing enabled I can see that generated test sources are marked both as Test Sources Root and Generated Sources Root. But when I try to manually set both flags it does not work - I get flags Sources Root and Generated Sources Root.
For me it looks like a bug.
Here's what worked for me. Create a directory in the Module root called generated and under it have two simlinks to <ProjectRoot>/out/production/<ProjectModule>/generated/ and <ProjectRoot>/out/test/<ProjectModule>/generated_tests/. Mark the first as Resource Root and the second as Test Resource Root.
I created the new directory and simlinks because it appears Intillij auto-marks <ProjectRoot>/out as Excluded.
I marked the directory as Test Resource Root so that Intellij doesn't try to compile the source twice to the same class. (Hint: big complains from the compiler.)
In the end, no red squiggles and auto-complete works.
Note: I didn't change the Intellij's generated sources directory for the module. (Well, I did to try another answer, but changed it back.)

TFS Build ignores configured Code Analysis ruleset

I have a solution that is using an hybrid .csproj and project.json combination (for nuget management purposes). So basically the "project.json" file is working as a "packages.config" file with a floating version capability.
This solution is using a custom RuleSet that is being distributed via Package, and is imported automatically. On the dev machine, works without a problem.
At the build machine (that is, inside the machine itself, working as an user) the solution also compiles without a problem.
However, when a vNext build (is this the name for the new build system?) is queued, it ignores completely the custom ruleset and just uses the StyleCop one (that is also included), which gives a bunch of warnings. Said warnings should not appear as the Custom RuleSet basically suppresses those warnings (ie: Warning SA1404: Code analysis suppression must have justification,
Warning SA1124: Do not use regions, etc)
As far as I have checked, there is no setting to specify the ruleset, and this works with XAML Builds. What is different in this new build system that is causing this? Is there a way to force/specify the Code Analysis Rule Set from the definition?
Thanks in advance for any help or advice on the matter.
Update/Edit
After debugging back and forth with the wonderful help of jessehouwing I must include the following detail on my initial report (that I ignored as I did not know that it was influential):
I am using SonarQube Analysis on my build definition.
I initially did not mention it as I did not know that it replaces the Code Analysis at Build Time (and not only when it "analyzes", as I thought).
If you are using the SonarQube tasks
The SonarQube tasks generate a new Code Analysis Ruleset file on the fly and will overwrite the one configured for the projects. These rulesets will be used regardless of what you've previously specified.
There is a trick to the naming of the rulesets through which you can include your own overrides.
More information on the structure can be found in the blog post from the SonarQube/Visual Studio team. Basically when you Bind your solution to SonarQube it will generate 2 ruleset files. One which will be overwritten during build, the other containing your customizations.
There is a toolkit/SDK to generate a SonarQube plugin for custom analyzers which allow you to import your rules into SonarQube, so it will know what rules to activate for your project(s).
If you're not using SonarQube
Yes you can specify the ruleset you want to use and force Code Analysis to run. It requires a couple of MsBuild arguments:
/p:RunCodeAnalysis=true /p:CodeAnalysisRuleset="PathToRuleset"
Or you can use my MsBuild helper extension to configure these settings with the help of a UI template:

Configure automatic excluded directories and other directory types when they are present

In the Community Edition when I import a module IntelliJ goes through and tries to figure out which directories are what types. The modules I deal with sometimes have a src and a test directory, which work fine, but more often than not the test directory is actually named tst. IntelliJ likes to mark is as a "Sources" directory rather than "Tests". With the tools I am working with, the dependency configuration and generation of the .iml file happens after this, as well as using a modified build system that is not IntelliJ supported. I have to build via commandline which generates a build folder which I would like to have automatically excluded.
So a couple questions.
Can I configure IntelliJ to automatically recognize different folder names "Tests" and mark them as such?
Can I configure IntelliJ to automatically mark a folder as excluded when it is present in a module?
You can't configure it, the list is hard-coded. However, I've added "tst" to the list of names that are recognized as test source roots; that fix will be included in IntelliJ IDEA 14.1.
You can add "build" to Settings | File Types | Files and folders to ignore. Then IntelliJ will ignore the directories and files named "build" anywhere in your project structure. Given that "build" is a fairly common name, this may or may not be what you want.

any way to run intellij community build from altered source?

I made changes to Intellij Community Edition (ce). I can compile and run those changes from within the IntelliJ editor. That launches a second instance of IntelliJ ce which is running from classes containing my changes. What I want to do is just run those changes without having to first load the source, compile and run from within IntelliJ.
Netbeans made this easy by just producing an executable as a result of the build. With Intellij, it's not at all clear what has to be done. I have tried the following-
using the Run configuration Intellij itself uses to run the altered classes- this includes setting the working directory , main class, vm options and classpath. Actually, this doesn't work for reasons unknown to me.
on someone's suggestion, running dist.gant in build. This blows up with very many errors which are not helpful (no class def found errors which indicate some confusion on Intellij's part on classpaths somewhere)
Running WinLauncher.exe under bin gives the error message that it can't find VM options file (although it's in bin, (and also for good measure under bin/win with the other files which are co-located with vmoptions in the intellij directory structure for Intellij proper. )
ALl this is just harder than it should be. The solution is to provide an executable as a result of the build and place it in a predictable location.
Has anyone ever actually DONE what I am trying to do- make changes to the community source then use the resultant editor not as a project you're working with in IntelliJ but as the Intellij editor you're working through?
FOLLOW UP
User60561 had the correct answer. Just to mop up the details, in artifacts, there is a compressed file (win.zip for Windows, mac.zip for Mac etc.). In order to run your snapshot, you have to unzip this archive (after which it will have the same name, minus the zip extension) then go into folder "bin". There you'll see two executables: idea.exe and idea64.exe, for 32 and 64 bit versions, respectively. Clicking on these runs your snapshot.
Adjusting contents of the files idea.exe.vmoptions and idea64.exe.vmoptions lets you set the VM parameters to suit yourself, typically people might want to give the VM more memory through the -Xmx value.
It seems straightforward:
To build the distribution archive of IntelliJ IDEA Community Edition, execute build.xml Ant build script in the root directory of the source code. The results of the build execution can be found at out/artifacts.
https://github.com/JetBrains/intellij-community#building
So download ant, and run ant in the directory that you have it stored in. Make sure to use the commandline to launch ant in order to make sure everything is working correctly.
Initially execute getPlugins.bat/sh, then:
Use update.bat/sh according to it's instructions
Or
Click on: Main Menu | Build | IntelliJ IDEA CE build
Copy content of intellij-community\out\deploy (lib, plugins folder) into existing IJ installation (sometimes it is better to delete existing folders if they contain older dependencies or when the installation was of Ultimate version)