/** * Detects deprecated jsp quote syntax e.g * <tags:tag attr1="<%="hello world"%>" attr2="<%=\"valid\"%>" attr3="<%= print.me("hello world") %>" /> * attr1 and attr3 are invalid syntax * * @param html * The content of the jsp * @param thePattern * The regular expression * @param meta * Meta data for the results */ protected void findDeprecatedJspQuotes(String html, Pattern thePattern, JspMetadata meta) { Matcher matcher = thePattern.matcher(html); while (matcher.find()) { String matched = matcher.group(1); if (StringUtils.isNotBlank(matched)) { Line lr = new Line(); lr.setDescription("Deprecated jsp syntax: " + matched); lr.setLineNumber(NewLineUtil.countNewLine(html, matcher.start())); lr.setPattern(matched); for (ResultProcessor hint : hints) { hint.process(lr); } meta.getDecorations().add(lr); } } }
public int compare(Line arg0, Line arg1) { if(arg0.getLineNumber() == null) { return -1; } if(arg1.getLineNumber() == null) { return 1; } return arg0.getLineNumber() - arg1.getLineNumber(); } };
Line result = new Line(); result.setDescription("Entity: " + ejbName + " does not expose required local interface."); result.setLineNumber(lineNumber); result.setPattern("//entity[ejb-name]/local"); result.setEffort(new StoryPointEffort(1)); MarkdownHint simpleHint = new MarkdownHint(); simpleHint.setMarkdown("Create a local interface for the Entity bean to support Container Managed Relationship (CMR)."); result.getHints().add(simpleHint); meta.getDecorations().add(result); Line result = new Line(); result.setDescription("Entity: " + ejbName + " does not expose required local-home interface."); result.setLineNumber(lineNumber); result.setPattern("//entity[ejb-name]/local-home"); result.setEffort(new StoryPointEffort(1)); result.getHints().add(simpleHint); meta.getDecorations().add(result);
@Override public void processMeta(FileMetadata meta) { try { String contents = FileUtils.readFileToString(meta.getFilePointer()); Matcher matcher = regexPattern.matcher(contents); while (matcher.find()) { String matched = matcher.group(1); Line lr = new Line(); lr.setDescription("Blacklist Namespace: " + matched); lr.setLineNumber(NewLineUtil.countNewLine(contents, matcher.start())); lr.setPattern(matched); meta.getDecorations().add(lr); } } catch (IOException e) { LOG.error("Exception reading content for: " + meta.getFilePointer().getAbsolutePath(), e); } } }
if(lr.getLineNumber() == null) { LOG.warn("Line number is null."); continue; blockSettings+=","; blockSettings+=lr.getLineNumber();
protected void findTaglib(String html, Pattern thePattern, JspMetadata meta) { Matcher matcher = thePattern.matcher(html); while (matcher.find()) { String matched = matcher.group(1); if (StringUtils.isNotBlank(matched)) { if (lineContainsNamespaceBlacklist(matched)) { Line lr = new Line(); lr.setDescription("Blacklist Namespace: " + matched); lr.setLineNumber(NewLineUtil.countNewLine(html, matcher.start())); lr.setPattern(matched); for (ResultProcessor hint : hints) { hint.process(lr); } meta.getDecorations().add(lr); } meta.getTaglibDependencies().add(matched); } } }
if (ranges[rIter].containsInteger(lr.getLineNumber())) { if (LOG.isDebugEnabled()) { LOG.debug("Line: " + lr.getLineNumber() + " within range[" + rIter + "]: " + ranges[rIter].toString());
protected void findImports(String html, Pattern thePattern, JspMetadata meta) { Matcher matcher = thePattern.matcher(html); while (matcher.find()) { String matched = matcher.group(1); if (StringUtils.isNotBlank(matched)) { String[] imports = StringUtils.split(matched, ","); if (imports != null) { for (String imp : imports) { imp = StringUtils.trim(imp); if (lineContainsClassBlacklist(imp)) { Line lr = new Line(); lr.setDescription("Blacklist: " + imp); lr.setLineNumber(NewLineUtil.countNewLine(html, matcher.start())); lr.setPattern(imp); for (ResultProcessor hint : hints) { hint.process(lr); } meta.getDecorations().add(lr); } meta.getClassDependencies().add(imp); } } } } }