Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Developer Toolset for Sonar-* Projects

License

NotificationsYou must be signed in to change notification settings

SonarSource/sonar-developer-toolset

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Toolset for the developers contributing tohttp://github.com/SonarSource andhttp://github.com/SonarCommunity repositories.

SonarLint

Dogfooding is a core principle at SonarSource. InstallingSonarLint in your favorite IDE is strongly recommended. Any feedback should be provided on:

The "connected mode" feature should also be enabled and configured withhttps://next.sonarqube.com/ orhttps://sonarcloud.io, depending on projects.

Eclipse users should also rely on the dogfooding Eclipse Update Site in order to experiment latest milestones:

Intellij users should also rely on the development marketplace in order to experiment latest milestones:

Git

If you have never used Git before, you need to do some setup first. Run the following commands so that Git knows your name and email.

git config --global user.name "Your Name"git config --global user.email "your@email.com"

Setup line endings preferences:

# For Unix/Mac usersgit config --global core.autocrlf inputgit config --global core.safecrlf true# For Windows usersgit config --global core.autocrlf truegit config --global core.safecrlf true

On Windows, you must explicitly tell Git to use long paths so you won't run into issues with files in deeply nested directories:

git config --global core.longpaths true

The merge is working pretty well on small repositories (with move and rename of files). But it's not working on large repositories as the detection of file renaming is O(n²), so we need to update some threshold (more explanations are available in this post :http://blogs.atlassian.com/2011/10/confluence_git_rename_merge_oh_my/) :

git config --global merge.renameLimit 10000

Commit messages

Commits must relate to a JIRA issue. Convention for messages inspired byhttp://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html :

  • The first line should be short (72 chars or less) and auto-descriptive in a format " ", for example "SONAR-1937 Code review"
  • Write your commit message in present imperative tense: "Fix bug" and not "Fixed bug".
  • The second line is blank.
  • Next lines optionally define a short summary of changes (wrap them to about 72 chars or so).

Example :

SONAR-2204,SONAR-2259 Fix URL encoding* For correct URL encoding we must encode parameters on lower level -in Query itself, but not in concrete implementation of Connector,because in Query we can distinguish concrete parts of URL.* Moreover in this case any additional encoding routines in Connectorare useless, so were removed.

If the change concerns a documentation-only change, then prefix it with "DOC ".

GitHub Configuration

The following points must be respected in the GitHub account settings:

  • If using your personal Github Account, the sonarsource email address must be set as primary
  • Uncheck "Keep my email addresses private"
  • The same name must be used in the Github profile and in the local git config key user.name

Eclipse Configuration

Eclipse settings are available in the directory/eclipse.

Imports

sonar-formatter.xml:positions new lines, comments, spaces, parentheses, etc. To be imported in Window > Preferences > Java > Code Style > Formatter.

sonar.importorder:organizes the "import" lines. To be imported in Window > Preferences > Java > Code Style > Organize Imports.

sonar-cleanup.xml:cleans up the code, by organizing imports, formating source code, correcting indentation, etc.To be imported in Window > Preferences > Java > Code Style > Clean Up.

In Windows > Preferences > Java > Editor > Save Actions, check the checkboxes to perform the cleanup at every "save" action. The "additional actions" displayed should be configured as well.

Eclipse Auto Save

Additional Configuration

In Window > Preferences > Maven > Errors/Warnings, set "Plugin execution not covered by lifecycle execution" to "Ignore". This will silence out error messages when importing your Maven projects

On Windows, in Window > Preferences > General > Workspace, set "Text file encoding" to "UTF-8" and "New text file line delimiter" to "Unix".

Code Style Configuration for Intellij

Eclipse Code Formatter

Intellij IDEA users must install the pluginAdapter for Eclipse Code Formatter:

  • CheckUse the Eclipse code formatter
  • SetEclipse workspace/project folder or config file tosonar-formatter.xml
  • CheckOptimize Imports (IntelliJ's Import Optimizing must be turned ON)
  • SetImport Order from file tosonar.importorderIntellij code style

General Editor

Go toPreferences/Settings > Editor > General:

  • CheckEnsure every saved file ends with a line break (under theOn Save section).

Go toPreferences/Settings > Editor > General > Auto import:

  • CheckOptimize imports on the fly for Java:

image

Automatic IntelliJ Code Style

You can either import the code style settings to IntelliJ IDEA by simply importingthis scheme in IDEA's code style settings (Editor > 'Code Style' > Java > 'Scheme' > ⚙️ > 'Import Scheme' > 'IntelliJ IDEA code style XML'),or you can apply the settings manually (see below). The result should be the same.

Manual Java Code Style

Follow these steps to set code style settings if not usingthis scheme from above.

Go toPreferences/Settings > Editor > Code Style > Java > Tabs and Indents:

  • SetTab size to 2
  • SetIndent to 2
  • SetContinuation indent to 2

Intellij imports

Go toPreferences/Settings > Editor > Code Style > Java > Wrapping and Braces > Method declaration parameter:

  • UncheckAlign when multiline

Go toPreferences/Settings > Editor > Code Style > Java > JavaDoc > Other:

  • UncheckGenerate "<p>" on empty lines

Go toPreferences/Settings > Editor > Code Style > Java > Imports

  • SetClass count to use import with '*' to 999
  • SetNames count to use static import with '*' to 999
  • Remove both lines fromPackages to Use Import with '*'
  • SetImport Layout to:
    • import all other imports
    • <blank line>
    • import static all other imports
    • import module imports

Intellij imports

Manual Kotlin Code Style

Go toPreferences/Settings > Editor > Code Style > Kotlin > Tabs and Indents:

  • SetTab size to 4
  • SetIndent to 4
  • SetContinuation indent to 4

Kotlin indents

Go toPreferences/Settings > Editor > Code Style > Kotlin > Imports:

  • SelectUse single name import inTop-Level Symbols
  • SelectUse single name import inJava Statics and Enum Members
  • Remove all entries from the listPackages to Use Imports with '*'

Kotlin imports

Go toPreferences/Settings > Editor > Code Style > Kotlin > Other:

  • CheckUse trailing comma

Kotlin other

For Kotlin, we use the default 140 character line length.

Manual XML Code Style

Go toPreferences/Settings > Editor > Code Style > XML > Tabs and Indents:

  • SetTab size to 2
  • SetIndent to 2
  • SetContinuation indent to 2

Intellij XML code style otherGo toPreferences/Settings > Editor > Code Style > XML > Other:

  • SetHard wrap at to 140
  • CheckKeep line breaks in text
  • CheckKeep white spaces

Intellij XML code style other

Manual Groovy Code Style

In order to correctly format build.gradle files, code style for Groovy has to be set.

Go toPreferences/Settings > Editor > Code Style > Groovy:

  • SetTab size to 2
  • SetIndent to 2
  • SetContinuation indent to 2

Intellij Groovy code style

Manual JavaScript/TypeScript Code Style

For Javascript (Typescript)Go toPreferences/Settings > Editor > Code Style > TypeScript > Imports:

  • CheckSort imported members
  • CheckSort imports by modules

Intellij typescript

We use a tool calledPrettier. In order to ensure it functions correctly, install thePrettier plugin.Once installed set the files as such:Intellij javascript prettier

The Prettier plugin requires IntelliJ Ultimate, but it's possible to use it without the plugin, e.g.like this.

Then to make sure prettier is run correctly, modify the on save actions:Intellij javascript onsave

Manual Scala Code Style

InstallScala plugin if not installed already

Go toPreferences/Settings > Editor > Code Style > Scala > Imports:

  • SetClass count to use import with '_' to 999
  • CheckMerge imports with the same prefix into one statement
  • Ensure to have the followingImport Layout (it should be the default):

Intellij scala import layout

(Optional) Build Configuration for Intellij

If the project uses maven, and you experience problems with the built-in build system (Build ➡️Rebuild Project) like long build times or build failures, you shoulddelegate the build to maven. Make sure to skip tests during the build:

Intellij-maven-runner

About

Developer Toolset for Sonar-* Projects

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp