Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Install SonarLint to check for SonarQube violations and CheckStyle-IDEA to apply checkstyle code formatting

Configure ONAP code formatting

...

for IntelliJ

ONAP is using google java style as mentioned in ONAP java style.  Import intellij-java-google-style.xml in intelliJ settings→code style→java and modify the following items,

...


SO Project: Method above won't work, install plugin Eclipse Code Formatter and configure it with the corresponding xml file (so/project-configs/code-tools/onap-eclipse-format.xml)

Configure ONAP code CheckStyle for IntelliJ

  1. Select, File, Settings, Tools, Checkstyle  
  2. Click on + beside the 'Configuration File' box to add a configuration
  3. Set description to something like 'ONAP Rules'
  4. Click on Browse to select the file <your_git_folder>/oparent/checkstyle/src/main/resources/onap-checkstyle/onap-java-style.xml  
    (assuming you have downloaded the oparent repo)
  5. Complete the Wizard (you can set exclusion properties if needed)
  6. Select the Configuration File you just added by selecting the relevant checkbox
  7. Click [OK] to close the settings popup

Configure ONAP copyright for IntelliJ

...

Code Block
titleReplace <organization name>
============LICENSE_START=======================================================
 Copyright (C) $today.year <organization name>
 ================================================================================
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
 
       http://www.apache.org/licenses/LICENSE-2.0
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 
 SPDX-License-Identifier: Apache-2.0
 ============LICENSE_END=========================================================


Set up SonarLint towards ONAP for IntelliJ

To bind your projects to the ONAP Sonar server, follow the instructions below. Your projects should be imported in to Eclipse before this.

  1. Select, File, Settings, Tools, Checkstyle  
  2. Right click on the project and select "SonarLint -> Bind to SonarQube or SonarCloud...".
  3. Select "sonarcloud" and press "Next".
  4. Click "Generate Token"
  5. A browser opens and you are taken to a Sonarcloud login page
  6. Login with an appropriate account from the list presented, most likely your GitHub account
  7. You are now directed to a sonarcloud token generation page
  8. Enter a name for your token and click "Generate"
  9. Copy the token hex string that is generated from the browser and paste it into the "Token" field in Eclipse and click "Next"
  10. In the "Organization" field, enter the string "onap" and press "Next"
  11. The Connection name "SonarCloud/onap" should be found by the system, click "Next"
  12. The connection should be successfully created, click "Finish"
  13. Press "Add...".
  14. Select the projects you want to add and press "OK".
  15. Press "Next".
  16. Start typing the name of your project, and it should appear in a list box where it should be selected.
  17. Press "Finish".

...