Skip to content

Commit

Permalink
fixing pmd warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
klieber committed May 14, 2014
1 parent e3406f4 commit d2b163b
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 41 deletions.
Expand Up @@ -12,7 +12,6 @@

import com.github.searls.jasmine.config.JasmineConfiguration;
import com.github.searls.jasmine.format.BuildsJavaScriptToWriteFailureHtml;
import com.github.searls.jasmine.runner.SpecRunnerTemplate;

public class HandlesRequestsForCoffee {

Expand All @@ -23,7 +22,7 @@ public class HandlesRequestsForCoffee {
public HandlesRequestsForCoffee(JasmineConfiguration configuration) {
this.configuration = configuration;
}

public void handle(Request baseRequest, HttpServletResponse response, Resource resource) throws IOException {
baseRequest.setHandled(true);
String javascript = null;
Expand Down
Expand Up @@ -3,7 +3,6 @@
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.IncorrectnessListener;
import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
import com.gargoylesoftware.htmlunit.WebClient;
Expand Down
Expand Up @@ -79,8 +79,8 @@ private WebDriver createCustomWebDriver() throws Exception {
private Object[] getWebDriverConstructorArguments(Constructor<? extends WebDriver> constructor) {
if (constructor.getParameterTypes().length == 0) {
return new Object[0];
} else
return new Object[] {getCapabilities()};
}
return new Object[] {getCapabilities()};
}

private DesiredCapabilities getCapabilities() {
Expand Down
Expand Up @@ -6,7 +6,6 @@
import com.github.searls.jasmine.model.ScriptSearch;
import com.github.searls.jasmine.runner.SpecRunnerTemplate;
import com.github.searls.jasmine.thirdpartylibs.ProjectClassLoaderFactory;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
Expand All @@ -16,13 +15,11 @@
import org.codehaus.plexus.resource.ResourceManager;
import org.codehaus.plexus.resource.loader.FileResourceLoader;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.nio.SelectChannelConnector;

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

public abstract class AbstractJasmineMojo extends AbstractMojo implements JasmineConfiguration {

Expand Down Expand Up @@ -136,9 +133,9 @@ public abstract class AbstractJasmineMojo extends AbstractMojo implements Jasmin
* &lt;source&gt;vendor/jquery.js&lt;/source&gt;
* &lt;/preloadSources&gt;
* </pre>
*
*
* <p>And jquery.js would load before all the other sources and specs.</p>
*
*
* @since 1.1.0
*/
@Parameter
Expand All @@ -149,7 +146,7 @@ public abstract class AbstractJasmineMojo extends AbstractMojo implements Jasmin
* and as a result the generated SpecRunner HTML files are set up in a way that you can't run
* your specs. Have no fear! Simply specify a custom spec runner template in the plugin configuration
* and make the changes you need.</p>
*
*
* <p>Potential values are a filesystem path, a URL, or a classpath resource. The default template is
* stored in <code>src/main/resources/jasmine-templates/SpecRunner.htmltemplate</code>, and the
* required template strings are tokenized in "$*$" patterns.</p>
Expand Down Expand Up @@ -181,24 +178,24 @@ public abstract class AbstractJasmineMojo extends AbstractMojo implements Jasmin

/**
* Target directory for files created by the plugin.
*
*
* @since 1.1.0
*/
@Parameter(defaultValue="${project.build.directory}${file.separator}jasmine")
protected File jasmineTargetDir;

/**
* Skip execution of tests.
*
*
* @since 1.1.0
* @see <a href="http://maven.apache.org/general.html#skip-test">http://maven.apache.org/general.html#skip-test</a>
*/
@Parameter(property="skipTests")
protected boolean skipTests;

/**
* Skip compilation and execution of tests.
*
*
* @since 1.3.1.3
* @see <a href="http://maven.apache.org/general.html#skip-test">http://maven.apache.org/general.html#skip-test</a>
*/
Expand All @@ -215,15 +212,15 @@ public abstract class AbstractJasmineMojo extends AbstractMojo implements Jasmin

/**
* Halt the build on test failure.
*
*
* @since 1.1.0
*/
@Parameter(property="haltOnFailure", defaultValue="true")
protected boolean haltOnFailure;

/**
* Timeout for spec execution in seconds.
*
*
* @since 1.1.0
*/
@Parameter(defaultValue="300")
Expand Down Expand Up @@ -255,31 +252,31 @@ public abstract class AbstractJasmineMojo extends AbstractMojo implements Jasmin

/**
* The name of the generated JUnit XML report.
*
*
* @since 1.1.0
*/
@Parameter(defaultValue="TEST-jasmine.xml")
protected String junitXmlReportFileName;

/**
* The name of the directory the specs will be deployed to on the server.
*
*
* @since 1.1.0
*/
@Parameter(defaultValue="spec")
protected String specDirectoryName;

/**
* The name of the directory the sources will be deployed to on the server.
*
*
* @since 1.1.0
*/
@Parameter(defaultValue="src")
protected String srcDirectoryName;

/**
* The source encoding.
*
*
* @since 1.1.0
*/
@Parameter(defaultValue="${project.build.sourceEncoding}")
Expand All @@ -288,7 +285,7 @@ public abstract class AbstractJasmineMojo extends AbstractMojo implements Jasmin
/**
* Keep the server alive after the <code>jasmine:test</code> goal exists.
* Useful if you need to run further analysis on your tests, like collecting code coverage.
*
*
* @since 1.3.1.0
*/
@Parameter(property="keepServerAlive", defaultValue="false")
Expand All @@ -304,15 +301,15 @@ public abstract class AbstractJasmineMojo extends AbstractMojo implements Jasmin
* &lt;include&gt;&#42;&#42;/&#42;.coffee&lt;/include&gt;
* &lt;/sourceIncludes&gt;
* </pre>
*
*
* <p>Default <code>sourceIncludes</code>:</p>
* <pre>
* &lt;sourceIncludes&gt;
* &lt;include&gt;&#42;&#42;/&#42;.js&lt;/include&gt;
* &lt;include&gt;&#42;&#42;/&#42;.coffee&lt;/include&gt;
* &lt;/sourceIncludes&gt;
* </pre>
*
*
* @since 1.1.0
*/
@Parameter
Expand All @@ -321,7 +318,7 @@ public abstract class AbstractJasmineMojo extends AbstractMojo implements Jasmin
/**
* <p>Just like <code>sourceIncludes</code>, but will exclude anything matching the provided patterns.</p>
* <p>There are no <code>sourceExcludes</code> by default.</p>
*
*
* @since 1.1.0
*/
@Parameter
Expand All @@ -338,15 +335,15 @@ public abstract class AbstractJasmineMojo extends AbstractMojo implements Jasmin
* &lt;include&gt;&#42;&#42;/&#42;.coffee&lt;/include&gt;
* &lt;/specIncludes&gt;
* </pre>
*
*
* <p>Default <code>specIncludes</code>:</p>
* <pre>
* &lt;specIncludes&gt;
* &lt;include&gt;&#42;&#42;/&#42;.js&lt;/include&gt;
* &lt;include&gt;&#42;&#42;/&#42;.coffee&lt;/include&gt;
* &lt;/specIncludes&gt;
* </pre>
*
*
* @since 1.1.0
*/
@Parameter
Expand All @@ -355,17 +352,17 @@ public abstract class AbstractJasmineMojo extends AbstractMojo implements Jasmin
/**
* <p>Just like <code>specIncludes</code>, but will exclude anything matching the provided patterns.</p>
* <p>There are no <code>specExcludes</code> by default.</p>
*
*
* @since 1.1.0
*/
@Parameter
private final List<String> specExcludes = Collections.emptyList();

/**
* <p>Used by the <code>jasmine:bdd</code> goal to specify port to run the server under.</p>
*
*
* <p>The <code>jasmine:test</code> goal always uses a random available port so this property is ignored.</p>
*
*
* @since 1.1.0
*/
@Parameter(property="jasmine.serverPort", defaultValue="8234")
Expand Down Expand Up @@ -395,7 +392,7 @@ public abstract class AbstractJasmineMojo extends AbstractMojo implements Jasmin
* implementation of the runner generator. Typically this is used when using different script runners.</p>
*
* <p>Some valid examples: DEFAULT, REQUIRE_JS</p>
*
*
* @since 1.1.0
*/
@Parameter(property="jasmine.specRunnerTemplate", defaultValue="DEFAULT")
Expand All @@ -415,22 +412,22 @@ public abstract class AbstractJasmineMojo extends AbstractMojo implements Jasmin
/**
* <p>Automatically refresh the test runner at the given interval (specified in seconds) when using the <code>jasmine:bdd</code> goal.</p>
* <p>A value of <code>0</code> disables the automatic refresh (which is the default).</p>
*
*
* @since 1.3.1.1
*/
@Parameter(property="jasmine.autoRefreshInterval", defaultValue="0")
protected int autoRefreshInterval;

/**
* <p>Control the Coffee Script compilation. e.g. When using RequireJS the compilation
* happens within the Coffee Script AMD loader plugin; we therefore need to disable the
* happens within the Coffee Script AMD loader plugin; we therefore need to disable the
* compilation here.</p>
*
* @since 1.3.1.4
*/
@Parameter(property="coffeeScriptCompilationEnabled", defaultValue="true")
protected boolean coffeeScriptCompilationEnabled;

/**
* <p>Type of {@link org.eclipse.jetty.server.Connector} to use on the jetty server.</p>
*
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/com/github/searls/jasmine/mojo/Context.java
Expand Up @@ -20,10 +20,7 @@
*/
package com.github.searls.jasmine.mojo;

import com.github.searls.jasmine.model.ScriptSearch;

import java.io.File;
import java.util.List;

public class Context {

Expand Down
Expand Up @@ -6,7 +6,6 @@

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
Expand Down
Expand Up @@ -8,15 +8,18 @@
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.io.InputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Date;

public abstract class AbstractThirdPartyLibsResourceHandler extends ResourceHandler {

@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
if (baseRequest.isHandled())
if (baseRequest.isHandled()) {
return;
}

String resourcePath = getResourcePath(target);
InputStream resource = findResource(resourcePath);
Expand All @@ -29,7 +32,7 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques
}
}

abstract protected InputStream findResource(String resourcePath);
protected abstract InputStream findResource(String resourcePath);

private String getResourcePath(String url) {
return url.replaceFirst("^/", "");
Expand Down

0 comments on commit d2b163b

Please sign in to comment.