npm-groovy-lint
Version:
Lint, format and auto-fix your Groovy / Jenkinsfile / Gradle files
31 lines (29 loc) • 626 B
JavaScript
// Explicit ArrayList instantiation
const rule = {
fix: {
label: "Replace ArrayList declaration by []",
type: "function",
func: (line) => {
return line.replace(/new ArrayList(.*)\)/gi, "[]");
},
},
tests: [
{
sourceBefore: `
List<String> commandArray = new ArrayList<String>()
`,
sourceAfter: `
List<String> commandArray = []
`,
},
{
sourceBefore: `
List<String> commandArray=new ArrayList<String> ()
`,
sourceAfter: `
List<String> commandArray=[]
`,
},
],
};
export { rule };