Wayback Machine
83 captures
16 Apr 2020 - 27 May 2025
Mar APR Jun
Previous capture 16 Next capture
2019 2020 2021
success
fail
About this capture
COLLECTED BY
Collection: Outlinks From Tweets
TIMESTAMPS
loading
The Wayback Machine - https://web.archive.org/web/20200416225629/https://code.visualstudio.com/docs/java/java-linting
This site uses cookies for analytics, personalized content and ads. By continuing to browse this site, you agree to this use. Learn more
Skip to content 
Visual Studio Code
  • Docs
  • Updates
  • Blog
  • API
  • Extensions
  • FAQ
  • Search
  • Search Search
  • Download VS Code Download VS Code Download

Version 1.44 is now available! Read about the new features and fixes from March.

Dismiss this update
'; document.body.appendChild(div.children[0]); }
  • Overview
  • Setup
    • Overview
    • Linux
    • macOS
    • Windows
    • Network
    • Additional Components
  • Get Started
    • Intro Videos
    • Tips and Tricks
    • User Interface
    • Themes
    • Settings
    • Key Bindings
    • Display Language
    • Telemetry
  • User Guide
    • Basic Editing
    • Extension Marketplace
    • IntelliSense
    • Code Navigation
    • Refactoring
    • Debugging
    • Version Control
    • Integrated Terminal
    • Tasks
    • Settings Sync
    • Snippets
    • Emmet
    • Command Line
    • Multi-root Workspaces
    • Accessibility
  • Languages
    • Overview
    • JavaScript
    • JSON
    • HTML
    • CSS, SCSS and Less
    • TypeScript
    • Markdown
    • PowerShell
    • C++
    • Java
    • PHP
    • Python
    • Go
    • T-SQL
    • C#
    • .NET Core
  • Node.js / JavaScript
    • Working with JavaScript
    • Node.js Tutorial
    • Node.js Debugging
    • Node.js Deployment
    • React Tutorial
    • Angular Tutorial
    • Vue Tutorial
    • Ember Tutorial
    • Debugging Recipes
    • Extensions
  • TypeScript
    • Tutorial
    • Compiling
    • Debugging
  • Python
    • Tutorial
    • Editing Code
    • Linting
    • Debugging
    • Environments
    • Testing
    • Jupyter Notebook Support
    • Python Interactive
    • Data Science Tutorial
    • Django Tutorial
    • Flask Tutorial
    • Create containers
    • Python on Azure
    • Settings Reference
  • Java
    • Getting Started
    • Navigate and Edit
    • Refactoring
    • Linting
    • Project Management
    • Build Tools
    • Run and Debug
    • Testing
    • Spring Boot
    • Application Servers
    • Java on Azure
    • Extensions
    • FAQ
  • C++
    • GCC on Windows
    • Microsoft C++
    • GCC on Linux
    • GCC on Windows Subsystem for Linux
    • Clang on macOS
    • Debugging
    • Editing
    • Settings
    • Enhanced colorization
    • c_cpp_properties.json
    • Debug configuration
    • Natvis framework
    • Pipe transport
    • Logging
    • FAQ
  • Containers
    • Overview
    • Node.js
    • Python
    • ASP.NET Core
    • Debug
    • Registries
    • Deploy to Azure
    • Choose a dev environment
    • Customize
  • Azure
    • Extensions
    • Deployment
    • Remote Debugging for Node.js
    • Docker
    • MongoDB
    • Kubernetes
    • Try Azure App Service
  • Remote
    • Overview
    • SSH
    • Containers
    • Visual Studio Online
    • Windows Subsystem for Linux
    • Tutorials
    • Tips and Tricks
    • Advanced Containers
    • Linux Prerequisites
    • FAQ

Topics

Java formatting and linting

Language Support for Java(TM) by Red Hat also provides formatting settings. You can export an Eclipse formatter file and then use it for your project in VS Code.

In addition, there are also the Checkstyle for Java and SonarLint extensions, which provide features for live linting and code analysis.

Checkstyle

With the Checkstyle for Java extension, you can use either existing checkstyle configurations (Google's or Sun's Check) or your own customized files for your project. When editing a Java file, the extension will check the file format and provide Quick Fixes if possible on the fly.

Set Checkstyle configuration file.

The Checkstyle for Java extension supports live linting.

And batch check.

The Problems panel will open when you click the Checkstyle status icon in the Status bar.

Set Checkstyle configuration file

Set Checkstyle configuration file

  • To set the configuration file, right-click the .xml file and select Set the Checkstyle Configuration File.

  • You can also trigger the command Checkstyle: Set Checkstyle Configuration File to choose the configuration file in the File Explorer. The extension looks for a checkstyle.xml file in your workspace to make Checkstyle configuration easier. You will also see the two built-in configurations:

    • Google's Check
    • Sun's Check
  • Command Checkstyle: Set the Checkstyle Configuration detects potential Checkstyle configuration files and lists them. You can also provide a configuration file by directly writing a URL in the input box.

You can also set the Checkstyle version by using the command Checkstyle: Set the Checkstyle Version.

The command will:

  • List the latest Checkstyle version from the main repo.
  • List all the downloaded versions.
  • List all the supported versions.
  • Mark the currently used version with a check symbol.

In addition, you can also bring any 3rd-party modules for Checkstyle by configuring its path. For example, after using the configuration below, you can add <module name="SingleBreakOrContinueCheck"/> or <module name="com.github.sevntu.checkstyle.checks.naming.SingleBreakOrContinueCheck"/> to checkstyle.xml to leverage those checks.

"java.checkstyle.modules": [ "${workspaceFolder}/src/main/resources/sevntu-checks-1.35.0.jar" ]

Check the style and fix the violations

Fix style violation

  • When editing a Java file, the extension will check the file format and provide Quick Fixes if possible. You can click the lightbulb button in the editor to show the available Quick Fixes.

For more details about Checkstyle for Java, visit its GitHub Repository.

SonarLint

The SonarLint extension lets you detect bugs and vulnerabilities as you write code in VS Code. Java is one of the languages supported, and the extension will run in the background and highlight source code that poses a quality or security concern.

Code Analysis on the fly

Issues are highlighted directly in the editor with hovers to provide detailed explanations.

SonarLint Bug

Issues found in the opened file can also be reviewed through the Problems panel of VS Code. When applicable, secondary code locations are mentioned so you can understand where the issue originates from (for example, the code path that led to a bug).

Rule documentation and remediation guidance

For any issue detected, SonarLint provides full documentation about the rule that was violated, and the coding best practice it relates to. This lets you understand why an issue is raised, and most importantly how to best fix it.

SonarLint Rules

Enabling more quality and security rules

By default, SonarLint provides a wide array of rules to detect bugs and vulnerabilities. More checks can be enabled through the SonarLint Rules view.

SonarLint Activate-Deactivate Rules

For more details about the SonarLint for VS Code extension, visit the SonarLint website.

4/9/2020

In this article there are 2 sectionsIn this article

  • Checkstyle
  • SonarLint
  • Hello from Seattle.
  • Follow @code
  • Support
  • Privacy
  • Terms of Use
  • License
Microsoft homepage Microsoft homepage © 2020 Microsoft