aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-docs/src/pages/analysis
diff options
context:
space:
mode:
authorG. Ann Campbell <ann.campbell@sonarsource.com>2018-06-26 17:14:10 +0200
committersonartech <sonartech@sonarsource.com>2018-06-29 09:10:15 +0200
commit7d56d0b2b288182336aca1931c5141684e6d57db (patch)
tree58595e6e53b77c47a27f967ac60a2da5661b7e79 /server/sonar-docs/src/pages/analysis
parent6bee2d5ea8bb8b6796cf8ece4f6937e7870459d2 (diff)
downloadsonarqube-7d56d0b2b288182336aca1931c5141684e6d57db.tar.gz
sonarqube-7d56d0b2b288182336aca1931c5141684e6d57db.zip
add PR, 'generic' docs and general data re analysis
Diffstat (limited to 'server/sonar-docs/src/pages/analysis')
-rw-r--r--server/sonar-docs/src/pages/analysis/generic_issue.md84
-rw-r--r--server/sonar-docs/src/pages/analysis/generic_test.md96
-rw-r--r--server/sonar-docs/src/pages/analysis/index.md50
-rw-r--r--server/sonar-docs/src/pages/analysis/scm_integration.md18
4 files changed, 248 insertions, 0 deletions
diff --git a/server/sonar-docs/src/pages/analysis/generic_issue.md b/server/sonar-docs/src/pages/analysis/generic_issue.md
new file mode 100644
index 00000000000..33c3ff456f6
--- /dev/null
+++ b/server/sonar-docs/src/pages/analysis/generic_issue.md
@@ -0,0 +1,84 @@
+---
+title: Generic Issue Data
+---
+
+SonarQube supports a generic import format for raising "external" issues in code. It is intended to allow you to import the issues from your favorite linter even if no plugin exists for it.
+
+External issues suffer from two important limitations:
+
+* they cannot be managed within SonarQube; for instance, there is no ability to mark them False Positive.
+* the activation of the rules that raise these issues cannot be managed within SonarQube. In fact, external rules are not visible in the Rules page or reflected in any Quality Profile.
+
+External issues and the rules that raise them must be managed in the configuration of your linter.
+
+## Import
+The analysis parameter `sonar.externalIssuesReportPaths` accepts a comma-delimited list of paths to reports.
+
+Each report must contain, at top-level, an array of `Issue` objects named `issues`.
+
+#### Issue fields:
+
+* `engineId` - string
+* `ruleId` - string
+* `primaryLocation` - Location object
+* `type` - string. One of BUG, VULNERABILITY, CODE_SMELL
+* `severity` - string. One of BLOCKER, CRITICAL, MAJOR, MINOR, INFO
+* `effortMinutes` - integer, optional. Defaults to 0
+* `secondaryLocations` - array of Location objects, optional
+
+#### Location fields:
+
+* `message` - string
+* `filePath` - string
+* `textRange` - TextRange object, optional for secondary locations only
+
+#### TextRange fields:
+
+* `startLine` - integer. 1-indexed
+* `endLine` - integer, optional. 1-indexed
+* `startColumn` - integer, optional. 0-indexed
+* `endColumn` - integer, optional. 0-indexed
+
+Here is an example of the expected format:
+
+ { "issues": [
+ {
+ "engineId": "test",
+ "ruleId": "rule1",
+ "severity":"BLOCKER",
+ "type":"CODE_SMELL",
+ "primaryLocation": {
+ "message": "fully-fleshed issue",
+ "filePath": "sources/A.java",
+ "textRange": {
+ "startLine": 30,
+ "endLine": 30,
+ "startColumn": 9,
+ "endColumn": 14
+ }
+ },
+ "effortMinutes": 90,
+ "secondaryLocations": [
+ {
+ "message": "cross-file 2ndary location",
+ "filePath": "sources/B.java",
+ "textRange": {
+ "startLine": 10,
+ "endLine": 10,
+ "startColumn": 6,
+ "endColumn": 38
+ }
+ }
+ ]
+ },
+ {
+ "engineId": "test",
+ "ruleId": "rule2",
+ "severity": "INFO",
+ "type": "BUG",
+ "primaryLocation": {
+ "message": "minimal issue raised at file level",
+ "filePath": "sources/Measure.java"
+ }
+ }
+ ]}
diff --git a/server/sonar-docs/src/pages/analysis/generic_test.md b/server/sonar-docs/src/pages/analysis/generic_test.md
new file mode 100644
index 00000000000..47a5850076e
--- /dev/null
+++ b/server/sonar-docs/src/pages/analysis/generic_test.md
@@ -0,0 +1,96 @@
+---
+title: Generic Test Data
+---
+
+Out of the box, SonarQube supports generic formats for test coverage and test execution import. If your coverage engines' native output formats aren't supported by your language plugins, simply covert them to these formats.
+
+## Generic Coverage
+Report paths should be passed in a comma-delimited list to:
+
+ * `sonar.coverageReportPaths`
+
+The supported format is described by the `sonar-generic-coverage.xsd`:
+
+ <xs:schema>
+ <xs:element name="coverage">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="file" minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="lineToCover" minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:attribute name="lineNumber" type="xs:positiveInteger" use="required"/>
+ <xs:attribute name="covered" type="xs:boolean" use="required"/>
+ <xs:attribute name="branchesToCover" type="xs:nonNegativeInteger"/>
+ <xs:attribute name="coveredBranches" type="xs:nonNegativeInteger"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="path" type="xs:string" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="version" type="xs:positiveInteger" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:schema>
+
+and looks like this:
+
+ <coverage version="1">
+ <file path="xources/hello/NoConditions.xoo">
+ <lineToCover lineNumber="6" covered="true"/>
+ <lineToCover lineNumber="7" covered="false"/>
+ </file>
+ <file path="xources/hello/WithConditions.xoo">
+ <lineToCover lineNumber="3" covered="true" branchesToCover="2" coveredBranches="1"/>
+ </file>
+ </coverage>
+
+The root node should be named `coverage`. Its version attribute should be set to `1`.
+
+Insert a `file` element for each file which can be covered by tests. Its `path` attribute can be either absolute or relative to the root of the module.
+Inside a `file` element, insert a `lineToCover` for each line which can be covered by unit tests. It can have the following attributes:
+* `lineNumber` (mandatory)
+* `covered` (mandatory): boolean value indicating whether tests actually hit that line
+* `branchesToCover` (optional): number of branches which can be covered
+* `coveredBranches` (optional): number of branches which are actually covered by tests
+
+## Generic Execution
+Report paths should be passed in a comma-delimited list to:
+
+* `sonar.testExecutionReportPaths`
+
+The supported format looks like this:
+
+ <testExecutions version="1">
+ <file path="testx/ClassOneTest.xoo">
+ <testCase name="test1" duration="5"/>
+ <testCase name="test2" duration="500">
+ <skipped message="short message">other</skipped>
+ </testCase>
+ <testCase name="test3" duration="100">
+ <failure message="short">stacktrace</failure>
+ </testCase>
+ <testCase name="test4" duration="500">
+ <error message="short">stacktrace</error>
+ </testCase>
+ </file>
+ </testExecutions>
+
+The root node should be named `testExecutions`. Its version attribute should be set to `1`.
+
+Insert a `file` element for each test file. Its `path` attribute can be either absolute or relative to the root of the module.
+
+**Note** unlike for coverage reports, the files present in the report must be test file names, not source code files covered by tests.
+
+Inside a `file` element, insert a `testCase` for each test run by unit tests. It can have the following attributes/children:
+
+* `testCase` (mandatory)
+ * `name` (mandatory): name of the test case
+ * `duration` (mandatory): long value in milliseconds
+
+ * `failure|error|skipped` (optional): if the test is not OK, report the cause with a message and a long description
+ * `message` (mandatory): short message describing the cause
+ * `stacktrace` (optional): long message containing details about `failure|error|skipped` status
diff --git a/server/sonar-docs/src/pages/analysis/index.md b/server/sonar-docs/src/pages/analysis/index.md
new file mode 100644
index 00000000000..8ddcdcd12d9
--- /dev/null
+++ b/server/sonar-docs/src/pages/analysis/index.md
@@ -0,0 +1,50 @@
+---
+title: Analyzing Source Code
+---
+
+Once the SonarQube platform has been installed, you're ready to install an analyzer and begin creating projects. To do that, you must install and configure the scanner that is most appropriate for your needs. Do you build with:
+
+<!-- sonarcloud -->
+* TravisCI for SonarCloud - [SonarCloud Travis addon](https://docs.travis-ci.com/user/sonarcloud/)
+<!-- /sonarcloud -->
+* Gradle - [SonarQube Scanner for Gradle](https://redirect.sonarsource.com/doc/gradle.html)
+* MSBuild - [SonarQube Scanner for MSBuild](https://redirect.sonarsource.com/doc/install-configure-scanner-msbuild.html)
+* Maven - use the [SonarQube Scanner for Maven](https://redirect.sonarsource.com/doc/install-configure-scanner-maven.html)
+* Jenkins - [SonarQube Scanner for Jenkins](https://redirect.sonarsource.com/plugins/jenkins.html)
+* VSTS / TFS - [SonarQube Extension for VSTS-TFS](https://redirect.sonarsource.com/doc/install-configure-scanner-tfs-ts.html)
+* Ant - [SonarQube Scanner for Ant](https://redirect.sonarsource.com/doc/install-configure-scanner-ant.html)
+* anything else (CLI) - [SonarQube Scanner](https://redirect.sonarsource.com/doc/install-configure-scanner.html)
+
+**Note** that we do not recommend running an antivirus scanner on the machine where a SonarQube analysis runs, it could result in unpredictable behavior.
+
+
+A project is created in the platform automatically on its first analysis. However, if you need to set some configuration on your project before its first analysis, you have the option of provisioning it via Administration options.
+
+## What does analysis produce?
+SonarQube can perform analysis on 20+ different languages. The outcome of this analysis will be quality measures and issues (instances where coding rules were broken). However, what gets analyzed will vary depending on the language:
+
+* On all languages, "blame" data will automatically be imported from supported SCM providers. Git and SVN are supported automatically. Other providers require additional plugins.
+* On all languages, a static analysis of source code is performed (Java files, COBOL programs, etc.)
+* A static analysis of compiled code can be performed for certain languages (.class files in Java, .dll files in C#, etc.)
+* A dynamic analysis of code can be performed on certain languages.
+
+## Will _all_ files be analyzed?
+By default, only files that are recognized by a language analyzer are loaded into the project during analysis. For example if your SonarQube instance had only SonarJava SonarJS on board, all .java and .js files would be loaded, but .xml files would be ignored. However, it is possible to import all text files in a project by setting **Settings > Exclusions > Files > Import unknown files** to true.
+
+## What happens during analysis?
+During analysis, data is requested from the server, the files provided to the analysis are analyzed, and the resulting data is sent back to the server at the end in the form of a report, which is then analyzed asynchronously server-side.
+
+Analysis reports are queued, and processed sequentially, so it is quite possible that for a brief period after your analysis log shows completion, the updated values are not visible in your SonarQube project. However, you will be able to tell what's going on because an icon will be added on the project homepage to the right of the project name. Mouse over it for more detail (and links if you're logged in with the proper permissions).
+
+![background task processing in progress.](/images/backgroundTaskProcessingInProgress.jpeg)
+
+
+The icon goes away once processing is complete, but if analysis report processing fails for some reason, the icon changes:
+
+![background task processing failed.](/images/backgroundTaskProcessingFailedIcon.jpeg)
+
+
+## F.A.Q.
+
+**Q.** Analysis errors out with `java.lang.OutOfMemoryError: GC overhead limit exceeded`. What do I do?
+**A.** This means your project is too large or too intricate for the scanner to analyze with the default memory allocation. To fix this you'll want to allocate a larger heap (using `-Xmx[numeric value here]`) to the process running the analysis. Some CI engines may give you an input to specify the necessary values, for instance if you're using a Maven Build Step in a Jenkins job to run analysis. Otherwise, use Java Options to set a higher value. Note that details of setting Java Options are omitted here because they vary depending on the environment.
diff --git a/server/sonar-docs/src/pages/analysis/scm_integration.md b/server/sonar-docs/src/pages/analysis/scm_integration.md
new file mode 100644
index 00000000000..6f6c685cf84
--- /dev/null
+++ b/server/sonar-docs/src/pages/analysis/scm_integration.md
@@ -0,0 +1,18 @@
+---
+title: SCM Integration
+---
+
+Collecting SCM data during code analysis can unlock a number of SonarQube features:
+
+* Automatic Issue Assignment
+* code annotation (blame data) in the Code Viewer
+* SCM-driven detection of new code (to help with Fixing the Water Leak). Without SCM data, SonarQube determines new code using analysis dates (to timestamp modification of lines).
+
+### Turning it on/off
+SCM integration requires support for your individual SCM provider. Git and SVN are supported by default.
+<!-- sonarqube -->
+For other SCM providers, see the Marketplace.
+<!-- /sonarqube -->
+
+Then, if need be, you can toggle it off at global/project level via administration settings.
+