pmd-ruby: checkstyle / formatting

This commit is contained in:
Andreas Dangel
2016-12-02 14:33:57 +01:00
parent 1a01f3757b
commit 4d94b71ffe
6 changed files with 51 additions and 45 deletions

View File

@ -1,6 +1,7 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cpd;
/**

View File

@ -1,6 +1,7 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cpd;
import java.util.ArrayList;

View File

@ -1,6 +1,7 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.ruby;
import net.sourceforge.pmd.lang.BaseLanguageModule;

View File

@ -1,17 +1,18 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd;
import java.util.Arrays;
import java.util.Collection;
import org.junit.runners.Parameterized.Parameters;
import net.sourceforge.pmd.lang.LanguageRegistry;
import net.sourceforge.pmd.lang.LanguageVersion;
import net.sourceforge.pmd.lang.ruby.RubyLanguageModule;
import org.junit.runners.Parameterized.Parameters;
public class LanguageVersionTest extends AbstractLanguageVersionTest {
public LanguageVersionTest(String name, String terseName, String version, LanguageVersion expected) {
@ -21,6 +22,6 @@ public class LanguageVersionTest extends AbstractLanguageVersionTest {
@Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] { { RubyLanguageModule.NAME, RubyLanguageModule.TERSE_NAME, "",
LanguageRegistry.getLanguage(RubyLanguageModule.NAME).getDefaultVersion() } });
LanguageRegistry.getLanguage(RubyLanguageModule.NAME).getDefaultVersion(), }, });
}
}

View File

@ -1,59 +1,39 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cpd;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import net.sourceforge.pmd.PMD;
import net.sourceforge.pmd.testframework.AbstractTokenizerTest;
import org.apache.commons.io.IOUtils;
import org.junit.Before;
import org.junit.Test;
import net.sourceforge.pmd.testframework.AbstractTokenizerTest;
public class RubyTokenizerTest extends AbstractTokenizerTest {
@Before
@Override
public void buildTokenizer() {
this.tokenizer = new RubyTokenizer();
this.sourceCode = new SourceCode(new SourceCode.StringCodeLoader(this.getSampleCode(), "server.rb"));
}
@Before
@Override
public void buildTokenizer() {
this.tokenizer = new RubyTokenizer();
this.sourceCode = new SourceCode(new SourceCode.StringCodeLoader(this.getSampleCode(), "server.rb"));
}
@Override
public String getSampleCode() {
return "require \"socket\"" + PMD.EOL +
"" + PMD.EOL +
"gs = TCPServer.open(0)" + PMD.EOL +
"addr = gs.addr" + PMD.EOL +
"addr.shift" + PMD.EOL +
"" + PMD.EOL +
"while true" + PMD.EOL +
" ns = gs.accept" + PMD.EOL +
" print(ns, \" is accepted\")" + PMD.EOL +
" Thread.start do" + PMD.EOL +
" s = ns # save to dynamic variable" + PMD.EOL +
" while s.gets" + PMD.EOL +
" s.write($_)" + PMD.EOL +
" end" + PMD.EOL +
" print(s, \" is " + PMD.EOL +
" gone" + PMD.EOL +
" and" + PMD.EOL +
" dead\")" + PMD.EOL +
" s.close" + PMD.EOL +
" end" + PMD.EOL +
"end" + PMD.EOL;
}
@Override
public String getSampleCode() {
try {
return IOUtils.toString(RubyTokenizerTest.class.getResourceAsStream("server.rb"), StandardCharsets.UTF_8);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@Test
public void tokenizeTest() throws IOException {
this.expectedTokenCount = 30;
super.tokenizeTest();
}
public static junit.framework.Test suite() {
return new junit.framework.JUnit4TestAdapter(RubyTokenizerTest.class);
@Test
public void tokenizeTest() throws IOException {
this.expectedTokenCount = 30;
super.tokenizeTest();
}
}

View File

@ -0,0 +1,22 @@
require "socket"
gs = TCPServer.open(0)
addr = gs.addr
addr.shift
while true
ns = gs.accept
print(ns, " is accepted")
Thread.start do
s = ns # save to dynamic variable
while s.gets
s.write($_)
end
print(s, " is
gone
and
dead")
s.close
end
end