Skip to content

Commit 6553f97

Browse files
committed
#3576 harper: remove obsolete linters and add new ones
Signed-off-by: Patrizio Bekerle <patrizio@bekerle.com>
1 parent 88bac52 commit 6553f97

6 files changed

Lines changed: 39 additions & 21 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
- Fixed the **Harper** settings status row so the `Status:` label is aligned with
1414
the status text again and the result text no longer repeats the `Status:`
1515
prefix in the **Settings dialog** (for [#3576](https://github.com/pbek/QOwnNotes/issues/3576))
16+
- Updated the **Harper** linter list in the **Settings dialog** to remove the
17+
upstream-deleted `Matcher` and `Wrong Quotes` rules and add `Quote Spacing`,
18+
`No French Spaces`, and `Wrong Apostrophe` instead (for
19+
[#3576](https://github.com/pbek/QOwnNotes/issues/3576))
1620

1721
## 26.4.20
1822

src/services/harperchecker.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,9 @@ void HarperChecker::readSettings() {
314314
<< QStringLiteral("SentenceCapitalization")
315315
<< QStringLiteral("RepeatedWords")
316316
<< QStringLiteral("LongSentences") << QStringLiteral("Spaces")
317-
<< QStringLiteral("Matcher")
317+
<< QStringLiteral("QuoteSpacing")
318+
<< QStringLiteral("NoFrenchSpaces")
319+
<< QStringLiteral("WrongApostrophe")
318320
<< QStringLiteral("CorrectNumberSuffix")
319321
<< QStringLiteral("UnclosedQuotes"))
320322
.toStringList();

src/services/harperclient.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,12 @@ QJsonObject buildHarperConfigurationObject(const HarperClient::RequestOptions &o
258258
QStringLiteral("AnA"),
259259
QStringLiteral("SentenceCapitalization"),
260260
QStringLiteral("UnclosedQuotes"),
261-
QStringLiteral("WrongQuotes"),
261+
QStringLiteral("WrongApostrophe"),
262+
QStringLiteral("QuoteSpacing"),
263+
QStringLiteral("NoFrenchSpaces"),
262264
QStringLiteral("LongSentences"),
263265
QStringLiteral("RepeatedWords"),
264266
QStringLiteral("Spaces"),
265-
QStringLiteral("Matcher"),
266267
QStringLiteral("CorrectNumberSuffix")};
267268
for (const QString &linter : knownLinters) {
268269
linters.insert(linter, options.enabledLinters.contains(linter));
@@ -893,15 +894,16 @@ QString HarperClient::categoryForRuleId(const QString &ruleId) {
893894
return QStringLiteral("Grammar");
894895
}
895896
if ((normalized == QStringLiteral("LongSentences")) ||
896-
(normalized == QStringLiteral("Matcher")) ||
897897
(normalized == QStringLiteral("SpelledNumbers"))) {
898898
return QStringLiteral("Style");
899899
}
900900
if ((normalized == QStringLiteral("Spaces")) ||
901-
(normalized == QStringLiteral("UnclosedQuotes"))) {
901+
(normalized == QStringLiteral("UnclosedQuotes")) ||
902+
(normalized == QStringLiteral("QuoteSpacing")) ||
903+
(normalized == QStringLiteral("NoFrenchSpaces"))) {
902904
return QStringLiteral("Punctuation");
903905
}
904-
if (normalized == QStringLiteral("WrongQuotes")) {
906+
if (normalized == QStringLiteral("WrongApostrophe")) {
905907
return QStringLiteral("Typography");
906908
}
907909

src/widgets/settings/harpersettingswidget.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ void HarperSettingsWidget::readSettings() {
102102
<< QStringLiteral("SentenceCapitalization")
103103
<< QStringLiteral("RepeatedWords")
104104
<< QStringLiteral("LongSentences") << QStringLiteral("Spaces")
105-
<< QStringLiteral("Matcher")
105+
<< QStringLiteral("QuoteSpacing")
106+
<< QStringLiteral("NoFrenchSpaces")
107+
<< QStringLiteral("WrongApostrophe")
106108
<< QStringLiteral("CorrectNumberSuffix")
107109
<< QStringLiteral("UnclosedQuotes"))
108110
.toStringList();
@@ -119,9 +121,12 @@ void HarperSettingsWidget::readSettings() {
119121
ui->harperCorrectNumberSuffixCheckBox->setChecked(
120122
enabledLinters.contains(QStringLiteral("CorrectNumberSuffix")));
121123
ui->harperSpacesCheckBox->setChecked(enabledLinters.contains(QStringLiteral("Spaces")));
122-
ui->harperMatcherCheckBox->setChecked(enabledLinters.contains(QStringLiteral("Matcher")));
123-
ui->harperWrongQuotesCheckBox->setChecked(
124-
enabledLinters.contains(QStringLiteral("WrongQuotes")));
124+
ui->harperQuoteSpacingCheckBox->setChecked(
125+
enabledLinters.contains(QStringLiteral("QuoteSpacing")));
126+
ui->harperNoFrenchSpacesCheckBox->setChecked(
127+
enabledLinters.contains(QStringLiteral("NoFrenchSpaces")));
128+
ui->harperWrongApostropheCheckBox->setChecked(
129+
enabledLinters.contains(QStringLiteral("WrongApostrophe")));
125130
ui->harperSpelledNumbersCheckBox->setChecked(
126131
enabledLinters.contains(QStringLiteral("SpelledNumbers")));
127132

@@ -173,11 +178,14 @@ QStringList HarperSettingsWidget::enabledLintersFromUi() const {
173178
if (ui->harperSpacesCheckBox->isChecked()) {
174179
linters.append(QStringLiteral("Spaces"));
175180
}
176-
if (ui->harperMatcherCheckBox->isChecked()) {
177-
linters.append(QStringLiteral("Matcher"));
181+
if (ui->harperQuoteSpacingCheckBox->isChecked()) {
182+
linters.append(QStringLiteral("QuoteSpacing"));
178183
}
179-
if (ui->harperWrongQuotesCheckBox->isChecked()) {
180-
linters.append(QStringLiteral("WrongQuotes"));
184+
if (ui->harperNoFrenchSpacesCheckBox->isChecked()) {
185+
linters.append(QStringLiteral("NoFrenchSpaces"));
186+
}
187+
if (ui->harperWrongApostropheCheckBox->isChecked()) {
188+
linters.append(QStringLiteral("WrongApostrophe"));
181189
}
182190
if (ui->harperSpelledNumbersCheckBox->isChecked()) {
183191
linters.append(QStringLiteral("SpelledNumbers"));

src/widgets/settings/harpersettingswidget.ui

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,12 @@
8181
<item row="1" column="0"><widget class="QCheckBox" name="harperLongSentencesCheckBox"><property name="text"><string>Long Sentences</string></property></widget></item>
8282
<item row="1" column="1"><widget class="QCheckBox" name="harperAnACheckBox"><property name="text"><string>An vs A</string></property></widget></item>
8383
<item row="1" column="2"><widget class="QCheckBox" name="harperUnclosedQuotesCheckBox"><property name="text"><string>Unclosed Quotes</string></property></widget></item>
84-
<item row="2" column="0"><widget class="QCheckBox" name="harperCorrectNumberSuffixCheckBox"><property name="text"><string>Correct Number Suffix</string></property></widget></item>
85-
<item row="2" column="1"><widget class="QCheckBox" name="harperSpacesCheckBox"><property name="text"><string>Spaces</string></property></widget></item>
86-
<item row="2" column="2"><widget class="QCheckBox" name="harperMatcherCheckBox"><property name="text"><string>Matcher</string></property></widget></item>
87-
<item row="3" column="0"><widget class="QCheckBox" name="harperWrongQuotesCheckBox"><property name="text"><string>Wrong Quotes</string></property></widget></item>
88-
<item row="3" column="1"><widget class="QCheckBox" name="harperSpelledNumbersCheckBox"><property name="text"><string>Spelled Numbers</string></property></widget></item>
84+
<item row="2" column="0"><widget class="QCheckBox" name="harperCorrectNumberSuffixCheckBox"><property name="text"><string>Correct Number Suffix</string></property></widget></item>
85+
<item row="2" column="1"><widget class="QCheckBox" name="harperSpacesCheckBox"><property name="text"><string>Spaces</string></property></widget></item>
86+
<item row="2" column="2"><widget class="QCheckBox" name="harperQuoteSpacingCheckBox"><property name="text"><string>Quote Spacing</string></property></widget></item>
87+
<item row="3" column="0"><widget class="QCheckBox" name="harperNoFrenchSpacesCheckBox"><property name="text"><string>No French Spaces</string></property></widget></item>
88+
<item row="3" column="1"><widget class="QCheckBox" name="harperWrongApostropheCheckBox"><property name="text"><string>Wrong Apostrophe</string></property></widget></item>
89+
<item row="3" column="2"><widget class="QCheckBox" name="harperSpelledNumbersCheckBox"><property name="text"><string>Spelled Numbers</string></property></widget></item>
8990
</layout>
9091
</widget>
9192
</item>

webpage/src/editor/harper.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ Open `Settings` and select `Editor -> Harper`.
4444
- `Unclosed Quotes`
4545
- `Correct Number Suffix`
4646
- `Spaces`
47-
- `Matcher`
48-
- `Wrong Quotes`
47+
- `Quote Spacing`
48+
- `No French Spaces`
49+
- `Wrong Apostrophe`
4950
- `Spelled Numbers`
5051

5152
Use `Test Connection` to verify that QOwnNotes can either start `harper-ls` in `Stdio` mode or

0 commit comments

Comments
 (0)