derrickoswald / CIMSpark

Spark access to Common Information Model (CIM) files
MIT License
15 stars 1 forks source link

codebase improvements #23

Open derrickoswald opened 4 years ago

derrickoswald commented 4 years ago

The wart remover (http://www.wartremover.org/) and scalastyle (http://www.scalastyle.org/) show a number of places where the codebase could be improved.

Some of the wart remover rules are stupid, like not allowing default method parameters - which is one of the best features of Scala, but it is what it is.

This issue tracks the changes that are needed to bring the codebase into compliance with a subset of the wart remover and scalastyle checks.

To work on this issue, in the CIMSpark pom.xml, add the wartremover compiler plugin to the net.alchim31.maven:scala-maven-plugin within the configuration, add wartremover options to the scala compiler args and comment out the fatal warnings flag:

<plugin>
    <groupId>net.alchim31.maven</groupId>
    <artifactId>scala-maven-plugin</artifactId>
    <version>${version.dependency.scala-maven-plugin}</version>
    <configuration>
        <scalaCompatVersion>${version.dependency.scala}</scalaCompatVersion>
        <scalaVersion>${version.dependency.scalalibrary}</scalaVersion>
        <archive>
            <addMavenDescriptor>false</addMavenDescriptor>
        </archive>
        <compilerPlugins>
            <compilerPlugin>
                <groupId>org.wartremover</groupId>
                <artifactId>wartremover_${version.dependency.scalalibrary}</artifactId>
                <version>${version.dependency.wartremover}</version>
            </compilerPlugin>
        </compilerPlugins>
        <displayCmd>true</displayCmd>
        <args>
            <arg>-deprecation</arg>
            <arg>-feature</arg>
            <arg>-unchecked</arg>
            <arg>-Ywarn-dead-code</arg>
            <arg>-Ywarn-unused</arg>
            <!-- arg>-Xfatal-warnings</arg -->
            <arg>-Xlint:_</arg>
            <arg>-target:jvm-1.8</arg>
            <!-- see https://github.com/wartremover/wartremover/blob/704113034f9d2829aa8d577ac4f059c2136c6781/core/src/main/scala/wartremover/warts/Unsafe.scala -->
            <!-- arg>-P:wartremover:only-warn-traverser:org.wartremover.warts.Any</arg -->
            <arg>-P:wartremover:only-warn-traverser:org.wartremover.warts.AsInstanceOf</arg>
            <!-- arg>-P:wartremover:only-warn-traverser:org.wartremover.warts.DefaultArguments</arg -->
            <arg>-P:wartremover:only-warn-traverser:org.wartremover.warts.EitherProjectionPartial</arg>
            <arg>-P:wartremover:only-warn-traverser:org.wartremover.warts.IsInstanceOf</arg>
            <arg>-P:wartremover:only-warn-traverser:org.wartremover.warts.NonUnitStatements</arg>
            <arg>-P:wartremover:only-warn-traverser:org.wartremover.warts.Null</arg>
            <arg>-P:wartremover:only-warn-traverser:org.wartremover.warts.OptionPartial</arg>
            <arg>-P:wartremover:only-warn-traverser:org.wartremover.warts.Product</arg>
            <arg>-P:wartremover:only-warn-traverser:org.wartremover.warts.Return</arg>
            <arg>-P:wartremover:only-warn-traverser:org.wartremover.warts.Serializable</arg>
            <arg>-P:wartremover:only-warn-traverser:org.wartremover.warts.StringPlusAny</arg>
            <arg>-P:wartremover:only-warn-traverser:org.wartremover.warts.Throw</arg>
            <arg>-P:wartremover:only-warn-traverser:org.wartremover.warts.TraversableOps</arg>
            <arg>-P:wartremover:only-warn-traverser:org.wartremover.warts.TryPartial</arg>
        </args>
    </configuration>
...

Recompile some module and then work on resolving the WARNINGs.