How to enable rules provided by StyleCop in Quality Profile - Sonar 5.1 - sonarqube5.1

I am trying to follow the link to enable StyleCop analysis for my .NET project. I am unable to set-up StyleCop rules in Quality Profile. I am using Sonar 5.1.
Basically I would like to incorporate StyleCop rules for the analysis rather than the default SONARWAY rules.
Any help in this regard will be highly appreciated.

This can be done by leveraging the Set-up StyleCop Rules for SONAR link. This provides a detail overview as to how the same can be achieved
To summarize, all we need to do is:
Choose Quality Profiles and select the default Sonar Way profile.
Choose Copy, and create a new quality profile named STYLECOP Profile.
Choose Set as Default in the “STYLECOP” entry to set it as the default for C# projects
Choose Rules in the top navigation toolbar and then set the Repository textbox in the left-hand column
Select StyleCop in the Repository list to see the list of rules
Select all the StyleCop rules (when using a mouse you can click on the first rule, scroll to the end, and Shift-click the last one)
Choose Bulk Change and then choose Activate In. From the drop-down list, choose the STYLECOP profile
After a few seconds, SonarQube tells you that rules were added to the STYLECOP quality profile
Re-running the analysis
Just as before, I run the commands (to set the PATH variable):
path=%path%;C:\Sq\MSBuild.SonarQube.Runner-1.0.1
MSBuild.SonarQube.Runner.exe begin /k:"StyleCopTest" /n:"StyleCopTest" /v:"1.0" /d:sonar.resharper.solutionFile="D:\TestStyleCop.sln"
msbuild "D:\TestStyleCop.sln"
MSBuild.SonarQube.Runner.exe end

Related

IntelliJ (2020.2) - How disable 'Build project automatically' for a project based on Gradle?

I am an Eclipse/STS user/developer, now trying to use IntelliJ Idea (CE)
2020.2.(1,2,3)
For a project based on Gradle, how spring-integration, when I open the IDE it happens the following
Ok, let the IDE load the project ... but
From above, that is the problem, I don't want that the IDE starts automatically to build/rebuild the project. I just need, open the project and that's all.
Observation: for example in Eclipse/STS exists the option to disable Build Automatically
I did do a research in the Web and I read the following posts and questions:
How to disable automatic gradle builds?
IntelliJ IDEA “Build project automatically” apparently not working
Intellij IDEA Java classes not auto compiling on save
Sadly the dialog options were changed but ...
Therefore:
From above, seems nothing to do.
Observation: from above observe the Build project automatically option is disabled
Even with that disabled and after to restart the IDE, I must always stop manually the build process
So what is missing? or Do I need a special extra plugin to accomplish my goal?
The images that you show indicate that you are building with Gradle, but the Compiler option that you disable is relevant for building projects with Idea not with Gradle.
For the 2020.2 version, you need to do the following:
Open the Setting > Build Tools page.
Disable the "Reload changes in build scripts" option.
This way you can manually control the reload. When you change the build script, you will see a small gradle icon in the right side of the editor.
For more info, refer to the IntelliJ IDEA help > Gradle section.
https://www.jetbrains.com/help/idea/work-with-gradle-projects.html#auto_reload
There are two different things in IntelliJ's Gradle support that sometimes confused: sync and build. Your pictures demonstrate sync process (note caption on the toolwindow). Word build is kind of misleading here.
What is sync? In gradle we use Groovy to define the build procedure. Groovy is an imperative programming language, so it's hard to predict resulting dependencies graph without actually executing the script. During the sync Idea executes configuration phase of gradle build (one that builds dependency graph), and obtains configured objects from the Gradle daemon. This information is used to setup project in the IDE: modules, libraries, dependencies, which sources are test, which are prod, etc.
Actual build is not happening during sync. You can convince yourself by adding syntax error to any source file, and observe that the sync succeeds. But build will fail if you invoke it.
In answer to the original question: you can't disable automatic build, because it is not enabled.
Is it possible to disable sync in Gradle project? Short answer - no. If you need a code browser, which is not required to understand all the cross-references in the source code, IDEA is not the best choice probably.
TL;DR;
Without sync IDE does not know which files are sources, and which are not. IDEA cannot open folders. It only can open projects. Good thing is that module can contain folder. So you can do the following: File | New | Project. Select Empty project, Next, select some random folder outside the source folder you want to open, Finish.
Then add new module:
Select Java in the left panel, everything else keep default, Next, Finish. Then in new module remove existing content root, and add folder with sources as new content root
Resulting project is mostly useless. Tons of red code (at least, unresolved symbols from external libraries), no inspections, no navigation, no sense. But it might be useful in some rare situations indeed.

Modify IntelliJ custom properties in plugin tests

I develop plugin for IntelliJ. How can I modify custom properties for my plugin tests?
For example I want to set idea.max.content.load.filesize property to, say, 100MiB
These are system properties, so java.lang.System#setProperty
Depending on the properties you wish to modify, you may be able to use idea.properties, which contains the "default properties used to run IntelliJ IDEA" (per the link you provided). To modify the file, you go to Help > Edit Custom Properties... (see these steps).
For example, I used this approach to address a problem where my machine's security software was blocking plugins that used IntelliJ's default config directory (C:\Users<user>\AppData...).
This is the Windows OS default Application Data directory and is included in the paths scanned by the security software. By moving my idea.properties file to a different directory (c:/development/idea/caches/), not automatically scanned by the security software, my plugins were no longer blocked.
It's a different use case from what you're describing, but may be an approach worth looking into.

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:

IntelliJ PMDPlugin custom ruleset

I want to use custom rulesets with the PMDPlugin in IntelliJ 2016.1 (on Windows).
The Plugin page tells me
PMD supports custom ruleset file, to configure goto settings -> PMD and add the rule set files that are required.
but i can't find any setting to configure the PMDPlugin (I'm using version 1.7.7). In fact when i'm searching for PMD the only item listed in the search results of the settings menu is the Plugin itself. And under Tools -> Run PMD the Custom Rules are greyed out.
I found on this page a possible solution but it doesn't worked for me. And if it would i would like to change the rulesets for different projects and i don't want to modify the IDEA rules for each.
Also i found a solution to set PMD as an external tool, but i like how other plugins (e.g. Checkstyle-IDEA) integrate into the IDE.
I also checked the QA-Plug with the PMD extension but there you can just select the settings and don't specify a custom ruleset.
I think you are looking in the wrong place. Go to File > Settings > Other Settings > PMD and there should be a + sign like below:
From there you can add your own custom rulesets (*.XML files).
PMD Plugin Version 1.8
Support Idea 2016.1
As it was touched on by #dambros: The PMD plug within the QAPlug plugin is configurable by clicking
Tools->QAPlug->Analyze Code...->Run with chosen profile
The above answers assume you are using the PMD plugin and NOT the PMDplug plugin that resides within the QAplug suite.

Any CPU platform and X86 Platform

I am really confused about target platform. For best results, to make my application run on any CPU, what target platform should be used. I tried Any CPU but my application does not run on Windows 7 with Access 2010 installed. It returns an error
The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine
Someone told me to avoid this error, change platform to X86. But I am unable to change that too. Dropdown menu contains only Any CPU.
What to do?
Thanks
In your connection string, try replacing
Provider=Microsoft.Jet.OLEDB.4.0
with
Provider=Microsoft.ACE.OLEDB.12.0;
In order to get new platforms, you can go into configuration manager and add a new one, but I thought x86 was one of the default ones provided. Here's a link for you. Quoted here in case MS moves their stuff around yet again.
Here are common procedures for creating and managing solution build
configurations:
To create a Solution Build Configuration
Open the Configuration Manager dialog box.
On the Active Solution Configurationdrop-down list, choose New.
The New Solution Configuration dialog box opens.
Type a name for the new solution build configuration in the Name text
box.
To use the same settings as those specified for another solution build
configuration, choose one from the drop-down list for the Copy
settings from textbox.
If you want to create one or more project configurations at the same
time, select the Create new project configurations check box.
To rename a Solution Build Configuration
Open the Configuration Manager dialog box.
On the Active Solution Configuration drop-down list, choose Edit.
The Edit Solution Configurations dialog box opens.
Select the solution build configuration name you want to change.
Select Rename, then type a new name for the configuration.
To select and edit a Solution Build Configuration
Open the Configuration Manager dialog box.
Select the desired solution build configuration from the Active
Solution Configuration drop-down menu at the top of the dialog box.
The Project Contexts panes display the properties of the active
solution build configuration.
Select any project available in the solution.
Select the desired project Configuration and Platform. Together, these
two settings specify the project configuration to be used.
If the project is to be included when you build this solution build
configuration, select the Build check box.