Skip to content

Commit c0426a7

Browse files
feat(core): more rules (#2107)
1 parent c6055ab commit c0426a7

35 files changed

+3637
-401
lines changed

harper-comments/tests/language_support_sources/clean.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ contract TestContract {
1111
* @notice This is another test function.
1212
* @dev It has another [link](https://example.com) embedded inside
1313
* @param p This is a parameter
14-
* @return fooBar The return value.
1514
*/
16-
function testFunction2(uint256 p) external returns (address fooBar) {}
15+
function testFunction2(uint256 p) external {}
1716

1817
// This is some gibberish to try to trigger a lint for sentences that continue for too long
1918
//

harper-comments/tests/language_support_sources/javadoc_clean_simple.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class TestClass {
22

33
/**
4-
* This is a Javadoc without any of the fancy frills that come with it.
4+
* This is a JavaDoc without any of the fancy frills that come with it.
55
*/
66
public static void main(String[] args) {
77
System.out.println("Hello world.");

harper-core/dictionary.dict

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28667,7 +28667,6 @@ howsoever/
2866728667
hoyden/NgSJV
2866828668
hoydenish/J
2866928669
hp/~N
28670-
hr/~NS
2867128670
ht/~N
2867228671
huarache/NSg
2867328672
hub/~NOSg
@@ -33014,7 +33013,6 @@ marital/~JY
3301433013
maritime/~J
3301533014
marjoram/Ng
3301633015
mark/~NgSVdGr
33017-
markdown/NgS
3301833016
marked/~JVtTU
3301933017
markedly/~R
3302033018
marker/~NgSV
@@ -52984,7 +52982,6 @@ JWT/Ng # JSON Web Token
5298452982
Jacoco/Sg
5298552983
JavaDoc/Sg
5298652984
JavaScript/ONSg # programming language
52987-
Javadoc/Sg
5298852985
JetBrains
5298952986
Jetpack/Og
5299052987
Jira/Og # issue tracker

harper-core/proper_noun_rules.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@
527527
"Las Vegas",
528528
"Los Angeles",
529529
"New York",
530+
"New York City",
530531
"Niagara Falls",
531532
"Novi Sad",
532533
"Panama Canal",

harper-core/src/char_ext.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub trait CharExt {
1313
///
1414
/// Checks whether the character is in the set (A, E, I, O, U); case-insensitive.
1515
fn is_vowel(&self) -> bool;
16+
fn normalized(self) -> Self;
1617
}
1718

1819
impl CharExt for char {
@@ -27,6 +28,13 @@ impl CharExt for char {
2728
&& self.script() == Script::Latin
2829
}
2930

31+
fn normalized(self) -> Self {
32+
match self {
33+
'’' | '‘' | 'ʼ' | ''' => '\'',
34+
_ => self,
35+
}
36+
}
37+
3038
fn is_emoji(&self) -> bool {
3139
let Some(block) = unicode_blocks::find_unicode_block(*self) else {
3240
return false;

harper-core/src/char_string.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::char_ext::CharExt;
12
use std::borrow::Cow;
23

34
use smallvec::SmallVec;
@@ -58,12 +59,12 @@ impl CharStringExt for [char] {
5859
/// Convert a given character sequence to the standard character set
5960
/// the dictionary is in.
6061
fn normalized(&'_ self) -> Cow<'_, [char]> {
61-
if self.as_ref().iter().any(|c| char_to_normalized(*c) != *c) {
62+
if self.as_ref().iter().any(|c| c.normalized() != *c) {
6263
Cow::Owned(
6364
self.as_ref()
6465
.iter()
6566
.copied()
66-
.map(char_to_normalized)
67+
.map(|c| c.normalized())
6768
.collect(),
6869
)
6970
} else {
@@ -120,15 +121,6 @@ impl CharStringExt for [char] {
120121
}
121122
}
122123

123-
fn char_to_normalized(c: char) -> char {
124-
match c {
125-
'’' => '\'',
126-
'‘' => '\'',
127-
''' => '\'',
128-
_ => c,
129-
}
130-
}
131-
132124
macro_rules! char_string {
133125
($string:literal) => {{
134126
use crate::char_string::CharString;

0 commit comments

Comments
 (0)