2

I meet a problem when I compile spark version 1.3.1. When I compiled the original source codes provided by spark,it was OK. But when I added some source files into the mllib, it came up with errors,like:

  • message=File line length exceeds 100 characters

Based on the information at the end of compiling

  • [ERROR] Failed to execute goal org.scalastyle:scalastyle-maven-plugin:0.4.0:check (default) on project spark-mllib_2.10: Failed during scalastyle execution: You have 53 Scalastyle violation(s). -> [Help 1]

It should be because of the scalastyle test. I could finish my compile process by closing the validation of scalastyle.

But is there any other ways to handle this problem? I don't think just closing the validation is good enough

Example code of Errors:
good one

val implicitPrefs =  
    new BooleanParam(this, "implicitPrefs", "whether to use implicit preference", Some(false))

bad one

val implicitPrefs = new BooleanParam(this, "implicitPrefs", "whether to use implicit preference", Some(false))
zero323
  • 322,348
  • 103
  • 959
  • 935
Shifeng.Liu
  • 105
  • 2
  • 7
  • 2
    An obvious solution is not to break the style rules in the first place :) – zero323 Oct 20 '15 at 03:37
  • Thanks zero323. I totally agree with you, and i still wonder the restriction of file line length and the number of parameters. Is it to make the code elegant? – Shifeng.Liu Oct 20 '15 at 04:38
  • Line length restrictions are mostly practical. You can easily fit 100 character in a single line on a relatively small screen without using size 6 font or something similar. Not to mention it is usually easier to read shorter lines. Regarding number of parameters... It is a relatively good measure of code complexity. I would say that more than ten is a pretty good signal there is something really wrong going on. – zero323 Oct 20 '15 at 05:00
  • I got it. Thanks very much, I learn a lot from you:) – Shifeng.Liu Oct 20 '15 at 06:23

2 Answers2

0

You can also read two code files side by side if their line length has been limited to 80/100.

Scala Style also imposes worthwhile rules like braces around single if-else statements.

Dragonborn
  • 1,755
  • 1
  • 16
  • 37
0

I believe you should have some kind of xml configuration (e.g. scalastyle.xml) to set up scala rules for your project. So you might set up maxFileLength value up to you:

        <scalastyle>
        <name>.....</name>
        <check level="warning" class="org.scalastyle.file.FileLengthChecker" enabled="true">
          <parameters>
            <parameter name="maxFileLength">1000</parameter>
          </parameters>
        </check>
        </scalastyle>

http://www.scalastyle.org/rules-dev.html#org_scalastyle_file_FileLengthChecker

27P
  • 1,183
  • 16
  • 22