Skip to content
Permalink
Browse files
Add scalac warnings for unused imports
- cleans up unused imports using scalafix
- enables scalac warn-on-unused option
- adds support for version specific scalac options
- enables language existentials in 2.11
- does not organize imports, only removes unused

DAFFODIL-2145
  • Loading branch information
jw3 authored and tuxji committed Jun 26, 2020
1 parent 5a8bb80 commit f585bfabccc7699197fc2b44fc9be017c52414be
Showing 158 changed files with 30 additions and 426 deletions.
@@ -114,7 +114,9 @@ lazy val commonSettings = Seq(
"-Xfatal-warnings",
"-Xxml:-coalescing",
"-Xfuture"
),
),
// add scalac options that are version specific
scalacOptions ++= scalacCrossOptions(scalaVersion.value),
// Workaround issue that some options are valid for javac, not javadoc.
// These javacOptions are for code compilation only. (Issue sbt/sbt#355)
javacOptions in Compile in compile ++= Seq(
@@ -146,6 +148,18 @@ lazy val commonSettings = Seq(
parallelExecution in IntegrationTest := false
) ++ Defaults.itSettings

def scalacCrossOptions(scalaVersion: String) =
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, 11)) => Seq(
"-language:existentials",
"-Ywarn-unused-import"
)
case Some((2, 12)) => Seq(
"-Ywarn-unused:imports"
)
case _ => Seq.empty
}

lazy val nopublish = Seq(
publish := {},
publishLocal := {},
@@ -17,13 +17,10 @@

package org.apache.daffodil.blob

import org.junit.Assert._
import org.junit.Test
import java.io.File
import org.apache.daffodil.CLI.Util
import net.sf.expectit.matcher.Matchers.contains
import net.sf.expectit.matcher.Matchers.eof
import net.sf.expectit.Expect
import scala.io.Source

class TestBlob {
@@ -19,8 +19,6 @@ package org.apache.daffodil.executing

import org.junit.Assert._
import org.junit.Test
import scala.language.postfixOps
import scala.sys.process._
import org.apache.daffodil.CLI.Util
import net.sf.expectit.matcher.Matchers.contains
import net.sf.expectit.matcher.Matchers.matches
@@ -20,10 +20,8 @@ package org.apache.daffodil.performance
import org.junit.Assert._
import org.junit.Test
import org.apache.daffodil.CLI.Util
import net.sf.expectit.ExpectIOException
import net.sf.expectit.matcher.Matchers.contains
import net.sf.expectit.matcher.Matchers.eof
import net.sf.expectit.matcher.Matchers.anyString

class TestCLIPerformance {

@@ -17,9 +17,7 @@

package org.apache.daffodil.udf

import org.junit.AfterClass
import org.junit.Test
import org.junit.Assert._
import org.apache.daffodil.CLI.Util
import net.sf.expectit.matcher.Matchers.contains
import net.sf.expectit.matcher.Matchers.anyOf
@@ -18,18 +18,11 @@
package org.apache.daffodil

import java.io.FileOutputStream
import java.io.BufferedWriter
import java.io.BufferedReader
import java.io.OutputStreamWriter
import java.io.OutputStream
import java.io.InputStreamReader
import java.io.Writer
import java.io.FileInputStream
import java.io.ByteArrayInputStream
import java.io.File
import java.nio.channels.Channels
import java.nio.file.Paths
import java.net.URI
import java.util.Scanner

import scala.xml.{SAXParseException, Node}
@@ -40,7 +33,7 @@ import org.apache.daffodil.util.Timer
import org.apache.daffodil.xml._
import org.apache.daffodil.exceptions.Assert
import org.apache.daffodil.compiler.Compiler
import org.apache.daffodil.api.{WithDiagnostics, URISchemaSource, ValidationMode, DFDL, DaffodilTunables}
import org.apache.daffodil.api.{WithDiagnostics, URISchemaSource, DFDL, DaffodilTunables}
import org.apache.daffodil.util.Logging
import org.apache.daffodil.util.LogLevel
import org.apache.daffodil.util.LogWriter
@@ -64,7 +57,6 @@ import org.rogach.scallop.ScallopOption
import scala.concurrent.duration.Duration
import scala.concurrent.Await
import org.apache.daffodil.xml.QName
import org.apache.daffodil.compiler._
import org.apache.daffodil.dsom.ExpressionCompilers
import org.apache.daffodil.compiler.InvalidParserException
import java.net.URI
@@ -28,29 +28,16 @@ import java.util.zip.ZipException
import scala.collection.immutable.Queue
import scala.xml.Node

import org.apache.daffodil.ExecutionMode
import org.apache.daffodil.api.DFDL
import org.apache.daffodil.api.DaffodilSchemaSource
import org.apache.daffodil.api.DaffodilTunables
import org.apache.daffodil.api.URISchemaSource
import org.apache.daffodil.api.UnitTestSchemaSource
import org.apache.daffodil.api.ValidationMode
import org.apache.daffodil.api.ParseUnparsePolicyTunable
import org.apache.daffodil.dsom.ElementBase
import org.apache.daffodil.dsom.SchemaComponent
import org.apache.daffodil.dsom.SchemaComponentImpl
import org.apache.daffodil.dsom.SchemaSet
import org.apache.daffodil.exceptions.Assert
import org.apache.daffodil.externalvars.Binding
import org.apache.daffodil.externalvars.ExternalVariablesLoader
import org.apache.daffodil.oolag.OOLAG
import org.apache.daffodil.processors.DataProcessor
import org.apache.daffodil.processors.Processor
import org.apache.daffodil.processors.SchemaSetRuntimeData
import org.apache.daffodil.processors.VariableMap
import org.apache.daffodil.processors.parsers.NotParsableParser
import org.apache.daffodil.processors.unparsers.NotUnparsableUnparser
import org.apache.daffodil.schema.annotation.props.gen.ParseUnparsePolicy
import org.apache.daffodil.util.LogLevel
import org.apache.daffodil.util.Logging
import org.apache.daffodil.util.Misc
@@ -17,7 +17,6 @@

package org.apache.daffodil.dpath

import org.apache.daffodil.exceptions.ThrowsSDE
import org.apache.daffodil.exceptions.Assert

/*
@@ -28,7 +28,6 @@ import org.apache.daffodil.dsom.CompiledExpression
import org.apache.daffodil.dsom.ConstantExpression
import org.apache.daffodil.dsom.DPathCompileInfo
import org.apache.daffodil.exceptions.Assert
import org.apache.daffodil.oolag.OOLAG.OOLAGHost
import org.apache.daffodil.xml.NamedQName
import org.apache.daffodil.xml.QNameRegex
import org.apache.daffodil.BasicComponent
@@ -30,13 +30,8 @@ import java.math.{ BigDecimal => JBigDecimal, BigInteger => JBigInt }
import java.lang.{ Long => JLong, Integer => JInt, Boolean => JBoolean, Double => JDouble }
import org.apache.daffodil.util.Numbers
import org.apache.daffodil.api.WarnID
import org.apache.daffodil.infoset.NoNextElement
import org.apache.daffodil.infoset.OnlyOnePossibilityForNextElement
import org.apache.daffodil.infoset.SeveralPossibilitiesForNextElement
import org.apache.daffodil.util.LogLevel
import org.apache.daffodil.infoset.DataValue.DataValuePrimitive
import org.apache.daffodil.udf.UserDefinedFunctionService
import org.apache.daffodil.util.Maybe
import org.apache.daffodil.BasicComponent
import org.apache.daffodil.api.DaffodilTunables
import org.apache.daffodil.oolag.OOLAG.OOLAGHostImpl
@@ -28,7 +28,6 @@ import org.apache.daffodil.schema.annotation.props.NotFound
import org.apache.daffodil.schema.annotation.props.Found
import org.apache.daffodil.schema.annotation.props.FindPropertyMixin
import org.apache.daffodil.api.WarnID
import org.apache.daffodil.schema.annotation.props.PropTypes
import scala.collection.mutable

/**
@@ -22,21 +22,9 @@ import scala.xml._
import org.apache.daffodil.schema.annotation.props.gen.Choice_AnnotationMixin
import org.apache.daffodil.schema.annotation.props.gen.ChoiceAGMixin
import org.apache.daffodil.grammar.ChoiceGrammarMixin
import org.apache.daffodil.processors.RuntimeData
import org.apache.daffodil.processors.ChoiceRuntimeData
import org.apache.daffodil.processors.ElementRuntimeData
import org.apache.daffodil.infoset.ChoiceBranchEvent
import org.apache.daffodil.infoset.ChoiceBranchStartEvent
import org.apache.daffodil.infoset.ChoiceBranchEndEvent
import org.apache.daffodil.exceptions.Assert
import org.apache.daffodil.dpath.NodeInfo
import org.apache.daffodil.processors.ChoiceDispatchKeyEv
import org.apache.daffodil.schema.annotation.props.gen.YesNo
import org.apache.daffodil.api.WarnID
import org.apache.daffodil.schema.annotation.props.gen.ChoiceKeyKindType
import org.apache.daffodil.schema.annotation.props.Found
import org.apache.daffodil.processors.SimpleTypeRuntimeData
import org.apache.daffodil.schema.annotation.props.NotFound

/**
*
@@ -23,9 +23,7 @@ import scala.xml.NamespaceBinding
import org.apache.daffodil.xml.NamedQName
import java.lang.{ Long => JLong, Boolean => JBoolean }
import org.apache.daffodil.schema.annotation.props.Found
import org.apache.daffodil.oolag.OOLAG._
import org.apache.daffodil.infoset.DataValue.DataValuePrimitive
import org.apache.daffodil.processors.HasTunable
import org.apache.daffodil.BasicComponent

object ExpressionCompilers extends ExpressionCompilerClass {
@@ -19,7 +19,6 @@ package org.apache.daffodil.dsom

import scala.xml.Node
import org.apache.daffodil.dpath.NodeInfo
import org.apache.daffodil.xml.QName
import org.apache.daffodil.api.WarnID
import scala.xml.Text
import scala.xml.Comment
@@ -20,7 +20,6 @@ package org.apache.daffodil.dsom
import scala.xml.Node
import scala.xml.NodeSeq.seqToNodeSeq
import org.apache.daffodil.grammar.EmptyGram
import org.apache.daffodil.grammar.Gram
import org.apache.daffodil.processors._
import org.apache.daffodil.xml.XMLUtils
import org.apache.daffodil.xml.GlobalQName
@@ -29,7 +28,6 @@ import org.apache.daffodil.dpath.NodeInfo.PrimType
import org.apache.daffodil.util.Maybe
import org.apache.daffodil.grammar.primitives.{ SetVariable, NewVariableInstanceStart, NewVariableInstanceEnd }
import org.apache.daffodil.schema.annotation.props.Found
import org.apache.daffodil.exceptions.Assert

class DFDLDefineVariable(node: Node, doc: SchemaDocument)
extends DFDLDefiningAnnotation(node, doc) {
@@ -20,7 +20,6 @@ package org.apache.daffodil.dsom
import scala.xml.Node
import scala.xml.NodeSeq

import org.apache.daffodil.api.WarnID
import org.apache.daffodil.xml.NamedQName
import org.apache.daffodil.xml.NS
import org.apache.daffodil.xml.QName
@@ -25,10 +25,8 @@ import org.apache.daffodil.api._
import org.apache.daffodil.dsom.IIUtils._
import org.apache.daffodil.api.Diagnostic
import org.apache.daffodil.oolag.OOLAG
import org.xml.sax.SAXException
import org.apache.daffodil.util.LogLevel
import org.apache.daffodil.util.Misc
import org.apache.daffodil.exceptions.Assert

/**
* represents one schema document file
@@ -23,9 +23,6 @@ import org.apache.daffodil.grammar.GrammarMixin
import org.apache.daffodil.grammar.primitives.InitiatedContent
import org.apache.daffodil.grammar.primitives.Terminator
import org.apache.daffodil.grammar.primitives.Initiator
import org.apache.daffodil.exceptions.Assert
import org.apache.daffodil.compiler.ForParser
import org.apache.daffodil.api.WarnID

trait InitiatedTerminatedMixin
extends GrammarMixin