Skip to content

Commit

Permalink
Fix most of the existing warnings on source code
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch committed Nov 1, 2016
1 parent 9190561 commit 36b2427
Show file tree
Hide file tree
Showing 82 changed files with 278 additions and 222 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ class ScalateEndpoint(component: ScalateComponent, uri: String, templateUri: Str

// now lets output the headers to the exchange
variableMap.get("headers") match {
case map: ju.Map[String, AnyRef] =>
for ((key, value) <- map) {
case map: ju.Map[_, _] =>
for ((key, value) <- map.asInstanceOf[ju.Map[String, AnyRef]]) {
out.setHeader(key, value)
}
case _ =>
Expand All @@ -111,4 +111,4 @@ class ScalateEndpoint(component: ScalateComponent, uri: String, templateUri: Str
val text: String = message
log.debug(text)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ class CamelScalateEndpointTest extends FunSuite {
val actualBody = out.getBody(classOf[String])
assume(actualBody != null, "Null body should not be returned when sending to: " + uri + " with out message: " + out)

expect(expectedResult) {
assertResult(expectedResult) {
actualBody.trim()
}
expect(headerValue) {
assertResult(headerValue) {
out.getHeader("cheese", classOf[String])
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,5 @@ class DefaultRenderContext(private val _requestUri: String, val engine: Template
}
}

def flush = out.flush
def flush() = out.flush
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import xml.{ Node, PCData, NodeSeq, NodeBuffer }
import collection.mutable.{ ListMap, LinkedHashSet, ListBuffer, HashMap }
import reflect.ClassTag

import scala.language.implicitConversions

object RenderContext {
val threadLocal = new ThreadLocal[RenderContext]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ import collection.generic.TraversableForwarder
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.ConcurrentHashMap

import scala.language.existentials

object TemplateEngine {
val log = Log(getClass); import log._

Expand Down Expand Up @@ -127,7 +129,7 @@ class TemplateEngine(var sourceDirectories: Traversable[File] = None, var mode:

private var booted = new AtomicBoolean()

def boot: Unit = {
def boot(): Unit = {
if (booted.compareAndSet(false, true)) {

if (allowReload) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ import util.parsing.input.{ Position, OffsetPosition }
import xml.NodeSeq
import org.fusesource.scalate.util.{ Log, SourceMapInstaller, SourceMap }

case class SourceLine(line: Int, source: String) {
case class SourceLine(
line: Int,
source: String
) {

def style(errorLine: Int): String = if (line == errorLine) "line error" else "line"

def nonBlank = source != null && source.length > 0
Expand Down Expand Up @@ -136,15 +140,17 @@ class ConsoleHelper(context: RenderContext) extends ConsoleSnippets {
* Returns the current template names used in the current context
*/
def templates: List[String] = attributes.get("scalateTemplates") match {
case Some(list: List[String]) => list.distinct.sortWith(_ < _)
case Some(list: List[_]) =>
list.map(_.asInstanceOf[String]).distinct.sortWith(_ < _)
case _ => Nil
}

/**
* Returns the current layouts used in the current context
*/
def layouts: List[String] = attributes.get("scalateLayouts") match {
case Some(list: List[String]) => list.distinct.sortWith(_ < _)
case Some(list: List[_]) =>
list.map(_.asInstanceOf[String]).distinct.sortWith(_ < _)
case _ => Nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class DefaultLayoutStrategy(val engine: TemplateEngine, val defaultLayouts: Stri
}

private def tryLayout(layoutTemplate: String, body: String, context: RenderContext): Boolean = {
def removeLayout = {
def removeLayout() = {
context.attributes("scalateLayouts") = context.attributeOrElse[List[String]]("scalateLayouts", List()).filterNot(_ == layoutTemplate)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import support.{ Code, AbstractCodeGenerator }
import collection.mutable.Stack
import util.Log

import scala.language.implicitConversions

object MustacheCodeGenerator extends Log

/**
Expand Down Expand Up @@ -133,4 +135,3 @@ class MustacheCodeGenerator extends AbstractCodeGenerator[Statement] {
Code(source.className, sb.code, Set(uri), sb.positions)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ import javax.ws.rs.{ PUT, DELETE }
/**
* @version $Revision: 1.1 $
*/
class ElementResource[K, E](element: E, container: Container[K, E]) {
class ElementResource[K, E](
element: E,
container: Container[K, E]
) {

@PUT
def put(updatedElement: E): Unit = {
Expand All @@ -31,7 +34,7 @@ class ElementResource[K, E](element: E, container: Container[K, E]) {
}

@DELETE
def delete: Unit = {
def delete(): Unit = {
container.remove(element)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ import org.fusesource.scalate._
import collection.mutable.LinkedHashMap
import support.{ Text, Code, AbstractCodeGenerator }
import support.RenderHelper
import collection.immutable.List
import scala.util.parsing.input.OffsetPosition

import scala.language.implicitConversions

/**
* Generates a scala class given a HAML document
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package org.fusesource.scalate.scuery

import xml.{ Node, NodeSeq }

import scala.language.implicitConversions

/**
* All the various implicit conversions for the scuery package
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package org.fusesource.scalate.scuery

import xml.{ Attribute, Document, Elem, Node, NodeSeq, Null, Text }

import scala.language.implicitConversions

object Transform {
implicit def toNodes(transform: Transform): NodeSeq = transform()
implicit def toTraversable(transform: Transform): Traversable[Node] = transform()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import collection.mutable.{ HashMap }
import xml.{ Attribute, Document, Elem, Node, NodeSeq, Null, Text }
import XmlHelper._

import scala.language.implicitConversions

/**
* Allows simple XML replacement rules to be registered
*
Expand Down Expand Up @@ -76,7 +78,7 @@ class Transformer {
if (size == 0) {
node match {
case e: Elem => replaceContent(e, apply(e.child, e +: ancestors))
case d: Document => apply(d.child)
case d: Node => apply(d.child)
case n => n
}
} else {
Expand Down Expand Up @@ -255,4 +257,4 @@ case class SXml(nodes: NodeSeq) {
*/
case class NodeAndAncestors(node: Node, ancestors: Seq[Node]) {
implicit def toNode = node
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ package org.fusesource.scalate.servlet
import java.util.Enumeration
import javax.servlet.{ FilterConfig, ServletContext, ServletConfig }

import scala.language.implicitConversions

object Config {
implicit def servletConfig2Config(servletConfig: ServletConfig) = new Config {
def getName = servletConfig.getServletName
Expand All @@ -44,4 +46,4 @@ trait Config {
def getServletContext: ServletContext
def getInitParameter(name: String): String
def getInitParameterNames: Enumeration[_]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import org.fusesource.scalate._
import collection.mutable.Stack
import support.{ Text, Code, AbstractCodeGenerator }

import scala.language.implicitConversions

class SspCodeGenerator extends AbstractCodeGenerator[PageFragment] {
override val stratumName = "SSP"

Expand Down Expand Up @@ -357,4 +359,3 @@ class SspCodeGenerator extends AbstractCodeGenerator[PageFragment] {
pass2
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import util.parsing.input.{ Positional, OffsetPosition, Position }
import org.fusesource.scalate.{ TemplateSource, Binding, TemplateEngine }
import org.fusesource.scalate.util.Log

import scala.language.postfixOps

object AbstractCodeGenerator extends Log

/**
Expand Down Expand Up @@ -93,9 +95,19 @@ abstract class AbstractCodeGenerator[T] extends CodeGenerator {
rc
}

def indent[T](op: => T): T = { indentLevel += 1; val rc = op; indentLevel -= 1; rc }
def indent[T](op: => T): T = {
indentLevel += 1
val rc = op
indentLevel -= 1
rc
}

def generate(engine: TemplateEngine, source: TemplateSource, bindings: Traversable[Binding], statements: List[T]): Unit = {
def generate(
engine: TemplateEngine,
source: TemplateSource,
bindings: Traversable[Binding],
statements: List[T]
): Unit = {

val packageName = source.packageName
val className = source.simpleClassName
Expand Down Expand Up @@ -146,7 +158,7 @@ abstract class AbstractCodeGenerator[T] extends CodeGenerator {

}

def generateInitialImports: Unit = {}
def generateInitialImports(): Unit = {}

def generate(statements: List[T]): Unit

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package support

import util.Objects

import scala.language.reflectiveCalls

/**
* A helper class for working with Boot style classes which
* take a TemplateEngine as a constructor argument and have a zero argument
Expand Down Expand Up @@ -33,4 +35,4 @@ object Boots {
case e: Throwable => throw new TemplateException("Failed to invoke " + bootClassName + ".run() : " + e, e)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import scala.collection.mutable.ListBuffer
import org.fusesource.scalate.{ Binding, TemplateEngine }
import org.fusesource.scalate.servlet.ServletRenderContext

import scala.language.reflectiveCalls

/**
* This class can precompile Scalate templates into JVM
* classes.
Expand Down Expand Up @@ -114,4 +116,4 @@ class Precompiler {
collected
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import java.io.{ PrintWriter, StringWriter, File }

import util.{ Log, IOUtil, ClassPathBuilder }

import scala.language.reflectiveCalls

object ScalaCompiler extends Log {

def create(engine: TemplateEngine): ScalaCompiler = {
Expand Down Expand Up @@ -213,4 +215,3 @@ class OsgiScalaCompiler(val engine: TemplateEngine, val bundle: Bundle)
)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import CharData._
import Integer._
import util.parsing.input.{ Positional, CharArrayReader }

import scala.language.postfixOps

/**
* Is a String with positioning information
*/
Expand Down Expand Up @@ -205,4 +207,4 @@ object CharData {
def isControl(c: Char) = Character.isISOControl(c)

def isControl(codepoint: Int) = Character.isISOControl(codepoint)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import org.fusesource.scalate.util._
object SiteGenerator extends Log
import SiteGenerator._

import scala.language.reflectiveCalls

/**
* This class generates static HTML files for your website using the Scalate templates, filters and wiki markups
* you are using.
Expand Down Expand Up @@ -161,4 +163,4 @@ class DummyRenderContext(val _requestUri: String, _engine: TemplateEngine, _out:

class DummyResponse {
def setContentType(value: String): Unit = {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package org.fusesource.scalate.support

import org.fusesource.scalate.util.Log

import scala.language.implicitConversions

/**
* A number of helper implicit conversions for use in templates
*/
Expand Down Expand Up @@ -55,4 +57,4 @@ object TemplateConversions {
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,15 @@ object BundleClassPathBuilder {
val dirs = bundle.getEntryPaths(fullName)
var nextEntry = prefetch()

def hasNext() = {
def hasNext = {
if (nextEntry == null)
nextEntry = prefetch()

nextEntry != null
}

def next() = {
if (hasNext()) {
if (hasNext) {
val entry = nextEntry
nextEntry = null
entry
Expand Down Expand Up @@ -303,4 +303,3 @@ object BundleClassPathBuilder {
if (t == null) default
else t
}

Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ class BindingsTest extends TemplateTestSupport {

val text1 = engine.layout(TemplateSource.fromText("foo2.ssp", "${year.toString}'s is the hippies era"))
info("Got: " + text1)
expect("1970's is the hippies era") { text1.trim }
assertResult("1970's is the hippies era") { text1.trim }

val text2 = engine.layout(TemplateSource.fromText("foo3.ssp", "${year.toString}'s is the hippies era"), Map("year" -> 1950))
info("Got: " + text2)
expect("1950's is the hippies era") { text2.trim }
assertResult("1950's is the hippies era") { text2.trim }
}
}

Expand Down
Loading

0 comments on commit 36b2427

Please sign in to comment.