Skip to content

Instantly share code, notes, and snippets.

Avatar

Clément Fournier oowekyala

View GitHub Profile
@oowekyala
oowekyala / pmd-jekyll.sh
Created Aug 23, 2017
Simple screen launcer for the PMD jekyll site
View pmd-jekyll.sh
#!/bin/bash
# Assuming GNU screen and bundler are installed, and `bundle install` has been run,
# this script starts the PMD documentation site server as a background screen.
# Kill the screen with option -k or --kill
# Install: change the PMD_GIT_DIR to match your pmd working directory, put in path and make executable
PMD_GIT_DIR="$HOME/Documents/Git/pmd"
SCRIPT_NAME=$(basename $0)
@oowekyala
oowekyala / fix-mvn
Created Mar 20, 2018
Fix PMD maven import setting all the modules to 1.7
View fix-mvn
#!/bin/bash
sed -i -e 's/1.5/1.7/g' .idea/compiler.xml
find . -name "*.iml" -exec sed -i -e 's/LANGUAGE_LEVEL="JDK_1_5"/LANGUAGE_LEVEL="JDK_1_7"/g' {} +
@oowekyala
oowekyala / App.java
Last active Mar 27, 2018
MWE RTFX style overlay
View App.java
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
import org.fxmisc.richtext.InlineCssTextArea;
import org.fxmisc.richtext.model.StyleSpans;
import org.fxmisc.richtext.model.StyleSpansBuilder;
import javafx.application.Application;
import javafx.scene.Scene;
View sitemap.xml
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://pmd.github.io/index.html</loc>
<priority>1</priority>
<changefreq>monthly</changefreq>
<lastmod>2018-05-18</lastmod>
</url>
@oowekyala
oowekyala / app.css
Created Jul 15, 2018
Removing scroll arrows on JavaFX context menu
View app.css
// Works at least on JFX 8 and 9
.context-menu .scroll-arrow {
-fx-padding: 0 0 0 0;
}
.context-menu .menu-item {
// OK this is weird but it does solve a padding bug on the context menu.
// Without it, items are offset to the bottom, and the last one is partially hidden
@oowekyala
oowekyala / MetricReporter.java
Created May 22, 2019
Generic metric reporter for PMD
View MetricReporter.java
package net.sourceforge.pmd.lang.metrics.internal;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import net.sourceforge.pmd.RuleContext;
import net.sourceforge.pmd.lang.ast.Node;
View MWE.java
import spoon.Launcher;
import spoon.reflect.declaration.CtClass;
import spoon.support.sniper.SniperJavaPrettyPrinter;
public class MWE {
/*
<dependency>
<groupId>fr.inria.gforge.spoon</groupId>
<artifactId>spoon-core</artifactId>
@oowekyala
oowekyala / README.md
Last active Aug 6, 2019
GSoC 2017 report -- Bringing Object-Oriented Metrics to PMD
View README.md
@oowekyala
oowekyala / BaseComparatorTest.java
Last active Jan 8, 2020
Generic contract test for a class implementing java.util.Comparator
View BaseComparatorTest.java
import static java.lang.Integer.signum;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
/** A generic test class to test the contract of a Comparator. */
public abstract class BaseComparatorTest<T> {
@oowekyala
oowekyala / JavaEscapeUtil.java
Created Jan 22, 2020
Escape routines for java text
View JavaEscapeUtil.java
class JavaEscapeUtil {
/**
* Replaces unprintable characters by their escaped (or unicode escaped)
* equivalents in the given string
*/
public static String escapeJava(String str) {
StringBuilder retval = new StringBuilder();
for (int i = 0; i < str.length(); i++) {
final char ch = str.charAt(i);
You can’t perform that action at this time.