Skip to content

Commit 7abe529

Browse files
authored
Merge branch 'languagetool-org:master' into master
2 parents ee55baf + 8df3a79 commit 7abe529

File tree

347 files changed

+196966
-21676
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

347 files changed

+196966
-21676
lines changed

.circleci/config.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,20 @@ jobs:
4343
MAVEN_OPTS: -Xmx3200m
4444
steps:
4545
- custom-checkout
46+
- install-project
4647
- run:
4748
name: test full
4849
command: |
49-
cd $CIRCLE_WORKING_DIRECTORY && mvn -pl '!languagetool-rpm-package' test -fae
50+
cd $CIRCLE_WORKING_DIRECTORY && mvn test -fae
5051
- save-test-results
5152
- run:
5253
name: deploy full
5354
command: |
54-
cd $CIRCLE_WORKING_DIRECTORY && mvn -s .circleci.settings.xml -pl '!languagetool-rpm-package' -DskipTests deploy
55+
cd $CIRCLE_WORKING_DIRECTORY && mvn -s .circleci.settings.xml -DskipTests deploy
5556
- save_cache:
5657
paths:
5758
- ~/.m2
5859
key: v1-dependencies-{{ checksum "/home/circleci/project/~/project/pom.xml" }}
59-
- trigger-premium-pipeline
6060
test-and-deploy-partial:
6161
resource_class: medium
6262
executor:
@@ -66,6 +66,7 @@ jobs:
6666
steps:
6767
- custom-checkout
6868
- get-diffs
69+
- install-project
6970
- run:
7071
name: test modules
7172
command: |
@@ -79,6 +80,7 @@ jobs:
7980
paths:
8081
- ~/.m2
8182
key: v1-dependencies-{{ checksum "/home/circleci/project/~/project/pom.xml" }}
83+
- trigger-premium-pipeline
8284
commands:
8385
custom-checkout:
8486
description: My custom checkout
@@ -104,7 +106,7 @@ commands:
104106
install-project:
105107
description: Run maven install
106108
steps:
107-
- run: cd $CIRCLE_WORKING_DIRECTORY && mvn -pl '!languagetool-rpm-package' clean install -DskipTests
109+
- run: cd $CIRCLE_WORKING_DIRECTORY && mvn clean install -DskipTests
108110
- run: cd $CIRCLE_WORKING_DIRECTORY && mvn dependency:go-offline
109111
save-test-results:
110112
steps:
@@ -121,11 +123,7 @@ commands:
121123
- run:
122124
name: Kick off new premium pipeline
123125
command: |
124-
curl --request POST \
125-
--url https://circleci.com/api/v2/project/gh/languagetooler-gmbh/languagetool-premium/pipeline \
126-
--header "Circle-Token: ${API_TOKEN}" \
127-
--header "Content-Type: application/json" \
128-
--data '{"branch":"master","parameters":{"run_on_pull":false, "os-sha": "${CIRCLE_SHA1}"}}'
126+
cd $CIRCLE_WORKING_DIRECTORY && .circleci/kick_off_premium.sh
129127
executors:
130128
docker-openjdk11:
131129
docker:

.circleci/kick_off_premium.sh

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/usr/bin/env bash
2+
#
3+
# LanguageTool, a natural language style checker
4+
# Copyright (C) 2021 Stefan Viol (https://stevio.de)
5+
#
6+
# This library is free software; you can redistribute it and/or
7+
# modify it under the terms of the GNU Lesser General Public
8+
# License as published by the Free Software Foundation; either
9+
# version 2.1 of the License, or (at your option) any later version.
10+
#
11+
# This library is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
# Lesser General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public
17+
# License along with this library; if not, write to the Free Software
18+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
19+
# USA
20+
#
21+
22+
# Exit script if you try to use an uninitialized variable.
23+
set -o nounset
24+
# Exit script if a statement returns a non-true return value.
25+
set -o errexit
26+
# Use the error status of the first failure, rather than that of the last item in a pipeline.
27+
set -o pipefail
28+
#
29+
# LanguageTool, a natural language style checker
30+
# Copyright (C) 2021 Stefan Viol (https://stevio.de)
31+
#
32+
# This library is free software; you can redistribute it and/or
33+
# modify it under the terms of the GNU Lesser General Public
34+
# License as published by the Free Software Foundation; either
35+
# version 2.1 of the License, or (at your option) any later version.
36+
#
37+
# This library is distributed in the hope that it will be useful,
38+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
39+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
40+
# Lesser General Public License for more details.
41+
#
42+
# You should have received a copy of the GNU Lesser General Public
43+
# License along with this library; if not, write to the Free Software
44+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
45+
# USA
46+
#
47+
48+
PROJECTS=""
49+
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
50+
if [[ "$BRANCH" != "master" ]]; then
51+
echo "No premium tests for $BRANCH."
52+
exit 0
53+
fi
54+
if grep -q -e "languagetool-core/.*" /home/circleci/git_diffs.txt; then
55+
PROJECTS="languagetool-core/"
56+
else
57+
if grep -q -e "languagetool-dev/.*" /home/circleci/git_diffs.txt; then PROJECTS="languagetool-dev/ $PROJECTS"; fi
58+
if grep -q -e "languagetool-language-modules/de/.*" /home/circleci/git_diffs.txt; then PROJECTS="languagetool-language-modules/de/ $PROJECTS"; fi
59+
if grep -q -e "languagetool-language-modules/en/.*" /home/circleci/git_diffs.txt; then PROJECTS="languagetool-language-modules/en/ $PROJECTS"; fi
60+
if grep -q -e "languagetool-language-modules/es/.*" /home/circleci/git_diffs.txt; then PROJECTS="languagetool-language-modules/es/ $PROJECTS"; fi
61+
if grep -q -e "languagetool-language-modules/fr/.*" /home/circleci/git_diffs.txt; then PROJECTS="languagetool-language-modules/fr/ $PROJECTS"; fi
62+
if grep -q -e "languagetool-language-modules/nl/.*" /home/circleci/git_diffs.txt; then PROJECTS="languagetool-language-modules/nl/ $PROJECTS"; fi
63+
if grep -q -e "languagetool-server/.*" /home/circleci/git_diffs.txt; then PROJECTS="languagetool-server/ $PROJECTS"; fi
64+
fi
65+
if [ -z "$PROJECTS" ]; then
66+
echo "No changes in any module detected"
67+
exit 0
68+
else
69+
PROJECTS=${PROJECTS::-1}
70+
fi
71+
curl --request POST \
72+
--url https://circleci.com/api/v2/project/gh/languagetooler-gmbh/languagetool-premium-modules/pipeline \
73+
--header "Circle-Token: ${API_TOKEN}" \
74+
--header "Content-Type: application/json" \
75+
--data "{\"branch\":\"master\",\"parameters\":{\"run_on_pull\":false, \"os-sha\": \"'${CIRCLE_SHA1}'\", \"os-changes\":\"$PROJECTS\"}}"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: 'Dependency Review'
2+
on:
3+
pull_request:
4+
paths-ignore:
5+
- '**pom.xml'
6+
permissions:
7+
contents: read
8+
jobs:
9+
dependency-review:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- run: 'echo "No review required" '
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: 'Dependency Review'
2+
on:
3+
pull_request:
4+
paths:
5+
- '**pom.xml'
6+
permissions:
7+
contents: read
8+
jobs:
9+
dependency-review:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: 'Checkout Repository'
13+
uses: actions/checkout@v3
14+
- name: 'Dependency Review'
15+
uses: actions/dependency-review-action@v1

build-zip.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
# fast way to build the ZIP for testing an deployment
33

4-
mvn -pl '!languagetool-http-client,!languagetool-wikipedia,!languagetool-office-extension,!languagetool-dev,!languagetool-rpm-package' clean package -DskipTests
4+
mvn -pl '!languagetool-http-client,!languagetool-wikipedia,!languagetool-office-extension,!languagetool-dev' clean package -DskipTests

create_release.sh renamed to deploy_release.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ TEST=$2
4141

4242
case "$TEST" in
4343
"fae" | "fn")
44-
COMMAND="mvn -Drevision=$VERSION clean package -$TEST"
44+
COMMAND="mvn -Drevision=$VERSION clean deploy -$TEST"
4545
echo "$COMMAND"
4646
$COMMAND
4747
;;
4848
"none")
49-
COMMAND="mvn -Drevision=$VERSION clean package -DskipTests"
49+
COMMAND="mvn -Drevision=$VERSION clean deploy -DskipTests"
5050
echo "$COMMAND"
5151
$COMMAND
5252
;;
5353
"full")
54-
COMMAND="mvn -Drevision=$VERSION clean package"
54+
COMMAND="mvn -Drevision=$VERSION clean deploy"
5555
echo "$COMMAND"
5656
$COMMAND
5757
;;

languagetool-commandline/src/main/java/org/languagetool/commandline/CommandLineTools.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ public static void printMatches(List<RuleMatch> ruleMatches,
184184
output += "[" + pRule.getSubId() + "]";
185185
}
186186
}
187+
output += " premium: " + Premium.get().isPremiumRule(match.getRule());
187188
int priorityForId = lang.getRulePriority(match.getRule());
188189
if (priorityForId != 0) {
189190
output += " prio=" + priorityForId;

languagetool-commandline/src/test/java/org/languagetool/commandline/MainTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public void testEnglishStdInJsonOutput() throws Exception {
313313
assertTrue("Got: " + output, output.contains("\"sentence\":\"This is an test.\""));
314314
assertTrue("Doesn't display Time", !output.contains("Time: "));
315315
assertTrue("Json start check", output.contains("{\"software\":{\"name\":\"LanguageTool\",\"version\":"));
316-
assertTrue("Json end check", output.endsWith("}]}"));
316+
assertTrue("Json end check", output.endsWith("[]}"));
317317
}
318318

319319
//test line mode vs. para mode

languagetool-core/pom.xml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,19 @@
328328
<groupId>com.vdurmont</groupId>
329329
<artifactId>emoji-java</artifactId>
330330
<version>${com.vdurmont.emoji-java.version}</version>
331+
<exclusions>
332+
<!-- The package `JSON-java` before 20180130 is vulnerable to Denial of service. -->
333+
<exclusion>
334+
<groupId>org.json</groupId>
335+
<artifactId>json</artifactId>
336+
</exclusion>
337+
</exclusions>
338+
</dependency>
339+
<!-- The package `JSON-java` before 20180130 is vulnerable to Denial of service. -->
340+
<dependency>
341+
<groupId>org.json</groupId>
342+
<artifactId>json</artifactId>
343+
<version>20200518</version>
331344
</dependency>
332345
<dependency>
333346
<groupId>org.projectlombok</groupId>
@@ -379,9 +392,11 @@
379392
<artifactId>protobuf-maven-plugin</artifactId>
380393
<version>${protobuf-maven-plugin.version}</version>
381394
<configuration>
382-
<protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}</protocArtifact>
395+
<protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}
396+
</protocArtifact>
383397
<pluginId>grpc-java</pluginId>
384-
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${io.grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
398+
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${io.grpc.version}:exe:${os.detected.classifier}
399+
</pluginArtifact>
385400
<!-- output into src/main/java, but don't ever clear it (would delete all regular source files) -->
386401
<outputDirectory>${project.build.sourceDirectory}/</outputDirectory>
387402
<clearOutputDirectory>false</clearOutputDirectory>

languagetool-core/src/main/java/org/languagetool/CheckResults.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
*/
1919
package org.languagetool;
2020

21+
import org.jetbrains.annotations.NotNull;
2122
import org.languagetool.rules.RuleMatch;
2223

24+
import java.util.ArrayList;
2325
import java.util.List;
2426
import java.util.Objects;
2527

@@ -30,6 +32,7 @@ public class CheckResults {
3032

3133
private List<RuleMatch> ruleMatches;
3234
private List<Range> ignoredRanges;
35+
private final List<SentenceRange> sentenceRanges = new ArrayList<>();
3336

3437
public CheckResults(List<RuleMatch> ruleMatches, List<Range> ignoredRanges) {
3538
this.ruleMatches = Objects.requireNonNull(ruleMatches);
@@ -44,12 +47,19 @@ public List<RuleMatch> getRuleMatches() {
4447
return ruleMatches;
4548
}
4649

50+
@NotNull
51+
public List<SentenceRange> getSentenceRanges() {
52+
return sentenceRanges;
53+
}
54+
public void addSentenceRanges(List<SentenceRange> sentenceRanges) {
55+
this.sentenceRanges.addAll(sentenceRanges);
56+
}
57+
4758
public void setIgnoredRanges(List<Range> ignoredRanges) {
4859
this.ignoredRanges = Objects.requireNonNull(ignoredRanges);
4960
}
5061

5162
public void setRuleMatches(List<RuleMatch> ruleMatches) {
5263
this.ruleMatches = Objects.requireNonNull(ruleMatches);
5364
}
54-
5565
}

0 commit comments

Comments
 (0)