Skip to content

Commit

Permalink
Merge branch 'master' into pr-3896
Browse files Browse the repository at this point in the history
  • Loading branch information
adangel committed Apr 21, 2022
2 parents 1ed96bb + a6d8c1b commit aa50b6f
Show file tree
Hide file tree
Showing 37 changed files with 1,063 additions and 190 deletions.
19 changes: 19 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -6584,6 +6584,25 @@
"contributions": [
"code"
]
},
{
"login": "jasonqiu98",
"name": "Jason Qiu",
"avatar_url": "https://avatars.githubusercontent.com/u/26801257?v=4",
"profile": "https://github.com/jasonqiu98",
"contributions": [
"code",
"doc"
]
},
{
"login": "LiGaOg",
"name": "LiGaOg",
"avatar_url": "https://avatars.githubusercontent.com/u/72175888?v=4",
"profile": "https://github.com/LiGaOg",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
Expand Down
2 changes: 1 addition & 1 deletion Dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def run_pmdtester
@base_branch = 'master'
@logger.info "\n\n--------------------------------------"
@logger.info "Run against #{@base_branch}"
@summary = PmdTester::Runner.new(get_args(@base_branch)).run
@summary = PmdTester::Runner.new(get_args(@base_branch, FALSE, 'target/diff1/patch_config.xml')).run

# move the generated report out of the way
FileUtils.mv 'target/reports/diff', 'target/diff2'
Expand Down
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ GEM
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
fugit (1.5.2)
et-orbi (~> 1.1, >= 1.1.8)
fugit (1.5.3)
et-orbi (~> 1, >= 1.2.7)
raabro (~> 1.4)
git (1.10.2)
rchardet (~> 1.8)
Expand All @@ -68,21 +68,21 @@ GEM
multipart-post (2.1.1)
nap (1.1.0)
no_proxy_fix (0.1.2)
nokogiri (1.13.3)
nokogiri (1.13.4)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
octokit (4.22.0)
faraday (>= 0.9)
sawyer (~> 0.8.0, >= 0.5.3)
open4 (1.3.4)
pmdtester (1.4.0)
pmdtester (1.4.1)
differ (~> 0.1)
liquid (~> 5.2)
logger-colors (~> 1.0)
nokogiri (~> 1.13)
rufus-scheduler (~> 3.8)
slop (~> 4.6)
public_suffix (4.0.6)
public_suffix (4.0.7)
raabro (1.4.0)
racc (1.6.0)
rchardet (1.8.0)
Expand All @@ -95,7 +95,7 @@ GEM
sawyer (0.8.2)
addressable (>= 2.3.5)
faraday (> 0.8, < 2.0)
slop (4.9.1)
slop (4.9.2)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
tzinfo (2.0.4)
Expand Down
10 changes: 5 additions & 5 deletions docs/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ GEM
coffee-script-source (1.11.1)
colorator (1.1.0)
commonmarker (0.23.4)
concurrent-ruby (1.1.9)
concurrent-ruby (1.1.10)
dnsruby (1.61.9)
simpleidn (~> 0.1)
em-websocket (0.5.3)
Expand Down Expand Up @@ -102,7 +102,7 @@ GEM
octokit (~> 4.0)
public_suffix (>= 3.0, < 5.0)
typhoeus (~> 1.3)
html-pipeline (2.14.0)
html-pipeline (2.14.1)
activesupport (>= 2)
nokogiri (>= 1.4)
http_parser.rb (0.8.0)
Expand Down Expand Up @@ -232,15 +232,15 @@ GEM
jekyll-seo-tag (~> 2.1)
minitest (5.15.0)
multipart-post (2.1.1)
nokogiri (1.13.3)
nokogiri (1.13.4)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
octokit (4.22.0)
faraday (>= 0.9)
sawyer (~> 0.8.0, >= 0.5.3)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (4.0.6)
public_suffix (4.0.7)
racc (1.6.0)
rb-fsevent (0.11.1)
rb-inotify (0.10.1)
Expand Down Expand Up @@ -269,7 +269,7 @@ GEM
thread_safe (~> 0.1)
unf (0.1.4)
unf_ext
unf_ext (0.0.8)
unf_ext (0.0.8.1)
unicode-display_width (1.8.0)
zeitwerk (2.5.4)

Expand Down
1 change: 1 addition & 0 deletions docs/_includes/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<ul id="mysidebar" class="nav">
<li class="sidebarTitle">{{sidebar[0].product}} {{sidebar[0].version | replace: '!PMD_VERSION!', site.pmd.version}}</li>
<div class="sidebarTitleDate">Release date: {{site.pmd.date}}</div>
{% for entry in sidebar %}
{% for folder in entry.folders %}
{% if folder.output contains "web" %}
Expand Down
6 changes: 6 additions & 0 deletions docs/css/pmd-customstyles.css
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,9 @@ details[open] summary {
.xpath-fun-doc .code-examples dt {
font-weight: normal;
}

div.sidebarTitleDate {
margin-top:2.5px;
margin-bottom:5px;
margin-left:5px;
}
4 changes: 2 additions & 2 deletions docs/css/theme-blue.css
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ li.sidebarTitle {
font-weight:normal;
font-size:130%;
color: #ED1951;
margin-bottom:10px;
margin-left: 5px;
margin-bottom:2.5px;
margin-left:5px;

}
4 changes: 2 additions & 2 deletions docs/css/theme-green.css
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ li.sidebarTitle {
font-weight:normal;
font-size:130%;
color: #ED1951;
margin-bottom:10px;
margin-left: 5px;
margin-bottom:2.5px;
margin-left:5px;

}
260 changes: 131 additions & 129 deletions docs/pages/pmd/projectdocs/credits.md

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions docs/pages/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,21 @@ This is a {{ site.pmd.release_type }} release.

### Fixed Issues
* core
* [#3881](https://github.com/pmd/pmd/issues/3881): \[core] SARIF renderer depends on platform default encoding
* [#3882](https://github.com/pmd/pmd/pull/3882): \[core] Fix AssertionError about exhaustive switch
* [#3884](https://github.com/pmd/pmd/issues/3884): \[core] XML report via ant task contains XML header twice
* doc
* [#2505](https://github.com/pmd/pmd/issues/2505): \[doc] Improve side bar to show release date
* java
* [#3889](https://github.com/pmd/pmd/pull/3889): \[java] Catch LinkageError in UselessOverridingMethodRule
* plsql
* [#3706](https://github.com/pmd/pmd/issues/3706): \[plsql] Parsing exception CURSOR statement with parenthesis groupings

### API Changes

### External Contributions
* [#3883](https://github.com/pmd/pmd/pull/3883): \[doc] Improve side bar by Adding Release Date - [@jasonqiu98](https://github.com/jasonqiu98)
* [#3928](https://github.com/pmd/pmd/pull/3928): \[plsql] Fix plsql parsing error in parenthesis groups - [@LiGaOg](https://github.com/LiGaOg)

{% endtocmaker %}

Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ public void start(String baseDir) {
}
renderer = createRenderer();
renderer.setWriter(writer);
renderer.start();
} catch (IOException ioe) {
throw new BuildException(ioe.getMessage(), ioe);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
package net.sourceforge.pmd.renderers;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Iterator;

import net.sourceforge.pmd.Report;
import net.sourceforge.pmd.RuleViolation;
import net.sourceforge.pmd.renderers.internal.sarif.SarifLog;
import net.sourceforge.pmd.renderers.internal.sarif.SarifLogBuilder;
import net.sourceforge.pmd.util.IOUtil;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
Expand Down Expand Up @@ -70,4 +72,9 @@ private void writeLog() throws IOException {
final String json = gson.toJson(sarifLog);
writer.write(json);
}

@Override
public void setReportFile(String reportFilename) {
this.setWriter(IOUtil.createWriter(StandardCharsets.UTF_8, reportFilename));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.apache.commons.io.output.WriterOutputStream;
import org.apache.commons.lang3.StringUtils;

import net.sourceforge.pmd.PMD;
import net.sourceforge.pmd.PMDVersion;
import net.sourceforge.pmd.Report;
import net.sourceforge.pmd.RuleViolation;
Expand Down Expand Up @@ -69,7 +68,7 @@ public String defaultFileExtension() {
public void start() throws IOException {
String encoding = getProperty(ENCODING);
String unmarkedEncoding = toUnmarkedEncoding(encoding);
lineSeparator = PMD.EOL.getBytes(unmarkedEncoding);
lineSeparator = System.lineSeparator().getBytes(unmarkedEncoding);

try {
xmlWriter.writeStartDocument(encoding, "1.0");
Expand Down
20 changes: 18 additions & 2 deletions pmd-core/src/main/java/net/sourceforge/pmd/util/IOUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,30 @@ public String run() {
* @return the writer, never null
*/
public static Writer createWriter(String reportFile) {
return createWriter(getDefaultCharset(), reportFile);
}

/**
* Creates a writer that writes to the given file or to stdout.
* The file is created if it does not exist.
*
* <p>Unlike {@link #createWriter(String)}, this method always uses
* the given charset. Even for writing to stdout. It never
* falls back to the default charset.</p>
*
* @param charset the charset to be used (required)
* @param reportFile the file name (optional)
* @return
*/
public static Writer createWriter(Charset charset, String reportFile) {
try {
if (StringUtils.isBlank(reportFile)) {
return createWriter();
return new OutputStreamWriter(System.out, charset);
}
Path path = new File(reportFile).toPath().toAbsolutePath();
Files.createDirectories(path.getParent()); // ensure parent dir exists
// this will create the file if it doesn't exist
return Files.newBufferedWriter(path, getDefaultCharset());
return Files.newBufferedWriter(path, charset);
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
Expand Down
6 changes: 1 addition & 5 deletions pmd-core/src/test/java/net/sourceforge/pmd/FooRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class FooRule extends AbstractRule {
public FooRule() {
setLanguage(LanguageRegistry.getLanguage(DummyLanguageModule.NAME));
setName("Foo");
setDescription("Description with Unicode Character U+2013: \u2013 .");
}

@Override
Expand All @@ -30,11 +31,6 @@ public String getRuleSetName() {
return "RuleSet";
}

@Override
public String getDescription() {
return "desc";
}

@Override
public void apply(List<? extends Node> nodes, RuleContext ctx) {
for (Node node : nodes) {
Expand Down
18 changes: 18 additions & 0 deletions pmd-core/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,22 @@ public void testWithShortFilenames() throws IOException {
Assert.assertEquals("sample.dummy:0:\tSampleXPathRule:\tTest Rule 2", actual);
}
}

@Test
public void testXmlFormatter() throws IOException {
buildRule.executeTarget("testXmlFormatter");

try (InputStream in = new FileInputStream("target/pmd-ant-xml.xml");
InputStream expectedStream = PMDTaskTest.class.getResourceAsStream("xml/expected-pmd-ant-xml.xml")) {
String actual = IOUtils.toString(in, StandardCharsets.UTF_8);
actual = actual.replaceFirst("timestamp=\"[^\"]+\"", "timestamp=\"\"");
actual = actual.replaceFirst("\\.xsd\" version=\"[^\"]+\"", ".xsd\" version=\"\"");

String expected = IOUtils.toString(expectedStream, StandardCharsets.UTF_8);
expected = expected.replaceFirst("timestamp=\"[^\"]+\"", "timestamp=\"\"");
expected = expected.replaceFirst("\\.xsd\" version=\"[^\"]+\"", ".xsd\" version=\"\"");

Assert.assertEquals(expected, actual);
}
}
}
Loading

0 comments on commit aa50b6f

Please sign in to comment.