Code style tool Spec-coding styles __

Source: Internet
Author: User
Tags checkstyle

Today, a test file is created in the Spark source directory, just to write the following Scala code:

Package Org.apache.spark

Import org.apache.spark.internal.Logging
import Org.apache.spark.rdd.RDD

Object Test extends Logging {
  def main (args:array[string]): unit = {
    Loginfo ("haha" + classof[rdd[_])
  }
  
   }
  

Obviously, there is no problem with the code, but there will be a compilation error, so that the Scalastyle_config.xml file into the. Idea directory, put in after the error. So I checked the file: It's a simple, Easy-to-use Code style Detection Tool that's very lightweight. Contribute to team style consistency. It's easy to integrate with Maven. Specific reference: Scalastyle tools

is originally specified in the Scalastyle_config.xml file

  <check level= "error" class= "Org.scalastyle.file.HeaderMatchesChecker" enabled= "true" >

Opened the file opening lisence detection. The test code I wrote was not preceded by a lisence comment. This is a bit more about code style, and it's a good idea to find out that style is controlled by code-style tools.

Before writing code, style all rely on their own control, everyone in SVN submitted code style is different, is not conducive to collaborative programming, the code is also more confusing. But with the code style gadget, it can have a certain binding effect. function is important, code style and later maintainability are also important. Find some code style related articles on the Internet, such as saving Java Code style obsessive-compulsive disorder Zhouyu has just given some more extensive discussion, in addition to local style control in the developer, but also in the submission of code to the good code style. The use of the Checkstyle Check Coding specification provides a way to install the Checkstyle plugin under the mainstream IDE (Idea and Eclipse).


In a word, the gadgets that make it easy for developers to work are not to be overlooked.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.