Skip to content

Commit

Permalink
feat: use mapstructure to split defintion types
Browse files Browse the repository at this point in the history
This allows each check to define its own fields without having to add them all
to one struct. It should also make the process of adding checks a little
more straightforward.

closes #15
  • Loading branch information
jdkato committed Mar 2, 2017
1 parent 70ffe9f commit 0fe6389
Show file tree
Hide file tree
Showing 40 changed files with 239 additions and 150 deletions.
235 changes: 164 additions & 71 deletions core/check.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions rule/Abbreviations.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
type: substitution
extends: substitution
message: Use '%s'
ignorecase: false
level: error
map:
swap:
'(?:eg)': e.g.,
'(?:ie)': i.e.,
'(?:e\.g\.)\s*': e.g.,
Expand Down
2 changes: 1 addition & 1 deletion rule/Annotations.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
message: "'%s' left in text"
type: existence
extends: existence
ignorecase: false
level: warning
tokens:
Expand Down
4 changes: 2 additions & 2 deletions rule/ComplexWords.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
type: substitution
extends: substitution
message: Consider using '%s' instead of '%s'
ignorecase: true
level: warning
map:
swap:
abundance: plenty
accelerate: speed up
accentuate: stress
Expand Down
2 changes: 1 addition & 1 deletion rule/Editorializing.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: existence
extends: existence
message: "Consider removing '%s'"
ignorecase: true
scope: text
Expand Down
4 changes: 2 additions & 2 deletions rule/GenderBias.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
type: substitution
extends: substitution
message: Consider using '%s' instead of '%s'
ignorecase: true
level: error
map:
swap:
(?:alumna|alumnus): graduate
(?:alumnae|alumni): graduates
(?:mother|father)land: native land
Expand Down
2 changes: 1 addition & 1 deletion rule/Hedging.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: existence
extends: existence
message: "Consider removing '%s'"
ignorecase: true
level: warning
Expand Down
4 changes: 2 additions & 2 deletions rule/Litotes.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
type: substitution
extends: substitution
message: Consider using '%s' instead of '%s'
ignorecase: true
level: warning
map:
swap:
no minor: major
no ordinary: extraordinary
no(?:t)? small: large
Expand Down
2 changes: 1 addition & 1 deletion rule/PassiveVoice.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: existence
extends: existence
message: "'%s' is passive voice"
ignorecase: true
level: warning
Expand Down
2 changes: 1 addition & 1 deletion rule/Redundancy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: existence
extends: existence
message: "'%s' is redundant"
ignorecase: true
level: error
Expand Down
2 changes: 1 addition & 1 deletion rule/Repetition.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: repetition
extends: repetition
message: "'%s' is repeated!"
level: error
scope: paragraph
Expand Down
2 changes: 1 addition & 1 deletion rule/Uncomparables.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: existence
extends: existence
message: "'%s' is not comparable"
ignorecase: true
level: error
Expand Down
4 changes: 2 additions & 2 deletions rule/Wordiness.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
type: substitution
extends: substitution
message: Consider using '%s' instead of '%s'
ignorecase: true
level: warning
map:
swap:
(?:give|gave) rise to: lead to
(?:previous|prior) to: before
a (?:large)? majority of: most
Expand Down
52 changes: 26 additions & 26 deletions rule/rule.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion styles/TheEconomist/Didactic.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: existence
extends: existence
message: "'%s' - Do not be too didactic"
description: "If too many sentences begin with '%s,' readers will think they are reading a textbook."
link: http://www.economist.com/styleguide/introduction
Expand Down
2 changes: 1 addition & 1 deletion styles/TheEconomist/Hectoring.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: existence
extends: existence
message: "'%s' - Do not be hectoring or arrogant"
description: "Those who disagree with you are not necessarily '%s.'"
link: http://www.economist.com/styleguide/introduction
Expand Down
2 changes: 1 addition & 1 deletion styles/TheEconomist/HorribleWords.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: existence
extends: existence
message: "'%s' - See section 'Horrible words'"
description: "Be aware that the use of '%s' may have an emetic effect on some of your readers."
link: http://www.economist.com/style-guide/horrible-words
Expand Down
2 changes: 1 addition & 1 deletion styles/TheEconomist/OughtShould.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: existence
extends: existence
message: Go easy on the oughts and shoulds
description: "The aim is not just to tell readers what you think, but to persuade them."
link: http://www.economist.com/styleguide/introduction
Expand Down
2 changes: 1 addition & 1 deletion styles/TheEconomist/OverusedWords.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: existence
extends: existence
message: "'%s' is overused"
description: "Nothing betrays the lazy writer faster than fly-blown phrases used in the belief that they are snappy, trendy or cool."
link: http://www.economist.com/style-guide/overused-words
Expand Down
4 changes: 2 additions & 2 deletions styles/TheEconomist/Punctuation.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
type: substitution
extends: substitution
message: Use '%s' instead of '%s'
level: error
scope: text
ignorecase: false
nonword: true
map:
swap:
e\.g\.: eg
i\.e\.: ie
\b(?:eg|ie)[^,]: eg, or ie,
2 changes: 1 addition & 1 deletion styles/TheEconomist/Slang.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: existence
extends: existence
message: "'%s' - See section 'Journalese and slang'"
scope: text
level: warning
Expand Down
6 changes: 3 additions & 3 deletions styles/TheEconomist/UnexpandedAcronyms.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
type: conditional
extends: conditional
message: "'%s' has no definition"
level: warning
scope: text
description: "Write the words in full on first appearance, unless the abbreviation or acronym is well known."
link: http://www.economist.com/style-guide/abbreviations
if: \b([A-Z]{3,5})\b
then: (?:\b[A-Z][a-z]+ )+\(([A-Z]{3,5})\)
first: \b([A-Z]{3,5})\b
second: (?:\b[A-Z][a-z]+ )+\(([A-Z]{3,5})\)
exceptions:
- ABC
- ADD
Expand Down
2 changes: 1 addition & 1 deletion styles/TheEconomist/UnnecessaryWords.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: existence
extends: existence
message: "'%s' - See section 'Unnecessary words'"
level: warning
scope: text
Expand Down
2 changes: 1 addition & 1 deletion styles/demo/CheckLinks.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: script
extends: script
scope: text
runtime: python3
exe: check_links.py
2 changes: 1 addition & 1 deletion styles/demo/CheckSpelling.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: script
extends: script
scope: text
runtime: node
exe: check_spelling.js
6 changes: 2 additions & 4 deletions styles/demo/CommasPerSentence.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
message: "More than 3 commas!"
type: occurrence
extends: occurrence
scope: sentence
max: 3
tokens:
- ','

token: ','
2 changes: 1 addition & 1 deletion styles/demo/EndingPreposition.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
message: "Don't end a sentence with '%s'"
type: existence
extends: existence
level: suggestion
scope: sentence
raw:
Expand Down
2 changes: 1 addition & 1 deletion styles/demo/HeadingStartsWithCapital.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
message: "'%s' should be capitalized"
type: existence
extends: existence
level: suggestion
scope: heading
raw:
Expand Down
2 changes: 1 addition & 1 deletion styles/demo/Hyphen.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: existence
extends: existence
message: "'%s' doesn't need a hyphen"
level: error
scope: text.html
Expand Down
2 changes: 1 addition & 1 deletion styles/demo/NounStrings.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
message: "'%s ...'"
type: repetition
extends: repetition
scope: sentence.md
max: 3
tokens:
Expand Down
5 changes: 2 additions & 3 deletions styles/demo/ParagraphLength.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
message: "Paragraphs should be less than 150 words"
type: occurrence
extends: occurrence
scope: paragraph.txt
level: suggestion
max: 150
tokens:
- \b(\w+)\b
token: \b(\w+)\b
5 changes: 2 additions & 3 deletions styles/demo/SentenceLength.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
message: "Sentences should be less than 25 words"
type: occurrence
extends: occurrence
scope: sentence
level: suggestion
max: 25
tokens:
- \b(\w+)\b
token: \b(\w+)\b
2 changes: 1 addition & 1 deletion styles/demo/Spacing.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: existence
extends: existence
message: "'%s' should have one space"
level: warning
scope: paragraph
Expand Down
2 changes: 1 addition & 1 deletion styles/write-good/Adverbs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: existence
extends: existence
message: "'%s' - Adverbs can weaken meaning"
ignorecase: true
level: warning
Expand Down
2 changes: 1 addition & 1 deletion styles/write-good/LexicalIllusions.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: repetition
extends: repetition
message: "'%s' is repeated!"
level: warning
ignorecase: true
Expand Down
2 changes: 1 addition & 1 deletion styles/write-good/NoCliches.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: existence
extends: existence
message: "'%s' is a cliché"
ignorecase: true
level: warning
Expand Down
2 changes: 1 addition & 1 deletion styles/write-good/PassiveVoice.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: existence
extends: existence
message: "'%s'"
ignorecase: true
level: warning
Expand Down
2 changes: 1 addition & 1 deletion styles/write-good/StartsWithSo.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: existence
extends: existence
message: "Don't start a sentence with '%s'"
ignorecase: true
level: error
Expand Down
2 changes: 1 addition & 1 deletion styles/write-good/ThereIs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: existence
extends: existence
message: "Don't start a sentence with '%s'"
ignorecase: true
level: error
Expand Down
2 changes: 1 addition & 1 deletion styles/write-good/TooWordy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: existence
extends: existence
message: "'%s' is too wordy"
ignorecase: true
level: warning
Expand Down

0 comments on commit 0fe6389

Please sign in to comment.