linter 0.1.2 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +11 -0
- data/.rubocop.yml +70 -0
- data/.rubocop_todo.yml +60 -0
- data/Gemfile +2 -2
- data/Gemfile.lock +28 -2
- data/README.md +12 -2
- data/Rakefile +5 -3
- data/bin/console +5 -4
- data/bin/linter +6 -0
- data/data/gender_association_wordlist.yml +6 -0
- data/data/misused_wordlist.yml +134 -0
- data/data/pronoun_association_wordlist.yml +11 -0
- data/lib/linter.rb +16 -3
- data/lib/linter/base_association.rb +27 -4
- data/lib/linter/cli.rb +14 -0
- data/lib/linter/gender_association.rb +4 -19
- data/lib/linter/misused_words.rb +25 -0
- data/lib/linter/pronoun_association.rb +22 -0
- data/lib/linter/version.rb +3 -1
- data/linter.gemspec +24 -20
- metadata +55 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4ee0b3799a3a7bc06b365832fde6a840832b24bffecb76912329e9ff483f5d37
|
|
4
|
+
data.tar.gz: 7a70ccf9e725a720bf947e2118db4d26950aca77595853a04bf00fc74f893026
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7a60ed737b52b82f31c1737f00920272a4c7c05c3203b3c37410aaae04a663851cd528e91ad6a118d9d5d8d79bea356772b33e6ab8a408e82002dd634d782d84
|
|
7
|
+
data.tar.gz: 01bd616cfad9a670272796a93990fa8d0d10a218dbed7c04e48416ffad9ccd344de602a060f3260e44265af9fc3a007e90916aadf7d0f36dceaa4a09bea17fc8
|
data/.gitlab-ci.yml
CHANGED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
|
2
|
+
|
|
3
|
+
require:
|
|
4
|
+
- rubocop-rspec
|
|
5
|
+
AllCops:
|
|
6
|
+
TargetRubyVersion: 2.6
|
|
7
|
+
# Cop names are displayed in offense messages by default. Change behavior
|
|
8
|
+
# by overriding DisplayCopNames, or by giving the `--no-display-cop-names`
|
|
9
|
+
# option.
|
|
10
|
+
DisplayCopNames: true
|
|
11
|
+
# Style guide URLs are not displayed in offense messages by default. Change
|
|
12
|
+
# behavior by overriding DisplayStyleGuide, or by giving the
|
|
13
|
+
# -S/--display-style-guide option.
|
|
14
|
+
DisplayStyleGuide: false
|
|
15
|
+
# Exclude some GitLab files
|
|
16
|
+
Exclude:
|
|
17
|
+
- '.gitlab/**/*'
|
|
18
|
+
|
|
19
|
+
Style/NumericLiteralPrefix:
|
|
20
|
+
Enabled: false
|
|
21
|
+
Metrics/BlockLength:
|
|
22
|
+
Enabled: false
|
|
23
|
+
Layout/LineLength:
|
|
24
|
+
Enabled: false
|
|
25
|
+
Style/Documentation:
|
|
26
|
+
Enabled: false
|
|
27
|
+
RSpec/FilePath:
|
|
28
|
+
Enabled: false
|
|
29
|
+
Metrics/AbcSize:
|
|
30
|
+
Max: 60
|
|
31
|
+
Metrics/MethodLength:
|
|
32
|
+
Max: 30
|
|
33
|
+
RSpec/ExampleLength:
|
|
34
|
+
Enabled: false
|
|
35
|
+
RSpec/MultipleExpectations:
|
|
36
|
+
Max: 2
|
|
37
|
+
RSpec/NestedGroups:
|
|
38
|
+
Max: 5
|
|
39
|
+
Layout/SpaceInsideHashLiteralBraces:
|
|
40
|
+
Enabled: false
|
|
41
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
|
42
|
+
Enabled: true
|
|
43
|
+
Layout/SpaceAroundMethodCallOperator:
|
|
44
|
+
Enabled: true
|
|
45
|
+
Layout/SpaceInsideBlockBraces:
|
|
46
|
+
Enabled: false
|
|
47
|
+
Style/SlicingWithRange:
|
|
48
|
+
Enabled: true
|
|
49
|
+
Style/ConditionalAssignment:
|
|
50
|
+
EnforcedStyle: assign_inside_condition
|
|
51
|
+
Lint/DeprecatedOpenSSLConstant:
|
|
52
|
+
Enabled: true
|
|
53
|
+
Lint/MixedRegexpCaptureTypes:
|
|
54
|
+
Enabled: true
|
|
55
|
+
Lint/RaiseException:
|
|
56
|
+
Enabled: true
|
|
57
|
+
Lint/StructNewOverride:
|
|
58
|
+
Enabled: true
|
|
59
|
+
Style/ExponentialNotation:
|
|
60
|
+
Enabled: true
|
|
61
|
+
Style/HashEachMethods:
|
|
62
|
+
Enabled: true
|
|
63
|
+
Style/HashTransformKeys:
|
|
64
|
+
Enabled: true
|
|
65
|
+
Style/HashTransformValues:
|
|
66
|
+
Enabled: true
|
|
67
|
+
Style/RedundantRegexpCharacterClass:
|
|
68
|
+
Enabled: true
|
|
69
|
+
Style/RedundantRegexpEscape:
|
|
70
|
+
Enabled: true
|
data/.rubocop_todo.yml
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# This configuration was generated by
|
|
2
|
+
# `rubocop --auto-gen-config`
|
|
3
|
+
# on 2020-06-06 22:58:53 +0200 using RuboCop version 0.85.0.
|
|
4
|
+
# The point is for the user to remove these configuration records
|
|
5
|
+
# one by one as the offenses are removed from the code base.
|
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
|
8
|
+
|
|
9
|
+
# Offense count: 1
|
|
10
|
+
# Cop supports --auto-correct.
|
|
11
|
+
# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
|
|
12
|
+
Layout/ExtraSpacing:
|
|
13
|
+
Exclude:
|
|
14
|
+
- 'linter.gemspec'
|
|
15
|
+
|
|
16
|
+
# Offense count: 3
|
|
17
|
+
# Cop supports --auto-correct.
|
|
18
|
+
Layout/SpaceAfterComma:
|
|
19
|
+
Exclude:
|
|
20
|
+
- 'lib/linter/gender_association.rb'
|
|
21
|
+
- 'lib/linter/misused_words.rb'
|
|
22
|
+
- 'lib/linter/pronoun_association.rb'
|
|
23
|
+
|
|
24
|
+
# Offense count: 1
|
|
25
|
+
# Cop supports --auto-correct.
|
|
26
|
+
# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator.
|
|
27
|
+
# SupportedStylesForExponentOperator: space, no_space
|
|
28
|
+
Layout/SpaceAroundOperators:
|
|
29
|
+
Exclude:
|
|
30
|
+
- 'linter.gemspec'
|
|
31
|
+
|
|
32
|
+
# Offense count: 4
|
|
33
|
+
Lint/IneffectiveAccessModifier:
|
|
34
|
+
Exclude:
|
|
35
|
+
- 'lib/linter/gender_association.rb'
|
|
36
|
+
- 'lib/linter/misused_words.rb'
|
|
37
|
+
- 'lib/linter/pronoun_association.rb'
|
|
38
|
+
|
|
39
|
+
# Offense count: 3
|
|
40
|
+
# Cop supports --auto-correct.
|
|
41
|
+
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
|
|
42
|
+
Lint/UselessAccessModifier:
|
|
43
|
+
Exclude:
|
|
44
|
+
- 'lib/linter/gender_association.rb'
|
|
45
|
+
- 'lib/linter/misused_words.rb'
|
|
46
|
+
- 'lib/linter/pronoun_association.rb'
|
|
47
|
+
|
|
48
|
+
# Offense count: 2
|
|
49
|
+
# Cop supports --auto-correct.
|
|
50
|
+
Style/ExpandPathArguments:
|
|
51
|
+
Exclude:
|
|
52
|
+
- 'linter.gemspec'
|
|
53
|
+
|
|
54
|
+
# Offense count: 1
|
|
55
|
+
# Cop supports --auto-correct.
|
|
56
|
+
# Configuration parameters: EnforcedStyle.
|
|
57
|
+
# SupportedStyles: always, always_true, never
|
|
58
|
+
Style/FrozenStringLiteralComment:
|
|
59
|
+
Exclude:
|
|
60
|
+
- 'linter.gemspec'
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
linter (0.1.
|
|
4
|
+
linter (0.1.6)
|
|
5
|
+
colorize (~> 0.8)
|
|
5
6
|
|
|
6
7
|
GEM
|
|
7
8
|
remote: https://rubygems.org/
|
|
8
9
|
specs:
|
|
10
|
+
ast (2.4.0)
|
|
9
11
|
coderay (1.1.3)
|
|
12
|
+
colorize (0.8.1)
|
|
10
13
|
diff-lcs (1.3)
|
|
11
14
|
method_source (1.0.0)
|
|
15
|
+
parallel (1.19.1)
|
|
16
|
+
parser (2.7.1.3)
|
|
17
|
+
ast (~> 2.4.0)
|
|
12
18
|
pry (0.13.1)
|
|
13
19
|
coderay (~> 1.1)
|
|
14
20
|
method_source (~> 1.0)
|
|
21
|
+
rainbow (3.0.0)
|
|
15
22
|
rake (10.5.0)
|
|
16
23
|
rb-readline (0.5.5)
|
|
24
|
+
regexp_parser (1.7.0)
|
|
25
|
+
rexml (3.2.4)
|
|
17
26
|
rspec (3.9.0)
|
|
18
27
|
rspec-core (~> 3.9.0)
|
|
19
28
|
rspec-expectations (~> 3.9.0)
|
|
@@ -27,6 +36,21 @@ GEM
|
|
|
27
36
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
28
37
|
rspec-support (~> 3.9.0)
|
|
29
38
|
rspec-support (3.9.3)
|
|
39
|
+
rubocop (0.85.0)
|
|
40
|
+
parallel (~> 1.10)
|
|
41
|
+
parser (>= 2.7.0.1)
|
|
42
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
43
|
+
regexp_parser (>= 1.7)
|
|
44
|
+
rexml
|
|
45
|
+
rubocop-ast (>= 0.0.3)
|
|
46
|
+
ruby-progressbar (~> 1.7)
|
|
47
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
|
48
|
+
rubocop-ast (0.0.3)
|
|
49
|
+
parser (>= 2.7.0.1)
|
|
50
|
+
rubocop-rspec (1.39.0)
|
|
51
|
+
rubocop (>= 0.68.1)
|
|
52
|
+
ruby-progressbar (1.10.1)
|
|
53
|
+
unicode-display_width (1.7.0)
|
|
30
54
|
|
|
31
55
|
PLATFORMS
|
|
32
56
|
ruby
|
|
@@ -38,6 +62,8 @@ DEPENDENCIES
|
|
|
38
62
|
rake (~> 10.0)
|
|
39
63
|
rb-readline
|
|
40
64
|
rspec (~> 3.0)
|
|
65
|
+
rubocop (~> 0.85)
|
|
66
|
+
rubocop-rspec (~> 1.39)
|
|
41
67
|
|
|
42
68
|
BUNDLED WITH
|
|
43
|
-
1.17.
|
|
69
|
+
1.17.2
|
data/README.md
CHANGED
|
@@ -27,6 +27,16 @@ Or install it yourself as:
|
|
|
27
27
|
text = 'Collaborate closely with the manager. Analytics all the way.'
|
|
28
28
|
Linter::GenderAssociation.analyze(text)
|
|
29
29
|
# #<OpenStruct feminine_coded_word_counts={"collaborate" => 1}, masculine_coded_word_counts={"analytics" => 1}, trend="neutral">
|
|
30
|
+
text = 'He was working at the bar.'
|
|
31
|
+
Linter::PronounAssociation.analyze(text)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## CLI Usage -> currently broken
|
|
35
|
+
|
|
36
|
+
```console
|
|
37
|
+
linter example.md
|
|
38
|
+
#<OpenStruct feminine_coded_word_counts={}, masculine_coded_word_counts={"analytical"=>1}, trend="strongly masculine-coded">
|
|
39
|
+
#<OpenStruct feminine_coded_word_counts={}, masculine_coded_word_counts={"he"=>1}, trend="masculine-coded">
|
|
30
40
|
```
|
|
31
41
|
|
|
32
42
|
## Development
|
|
@@ -37,7 +47,7 @@ To install this gem onto your local machine, run `bundle exec rake install`.
|
|
|
37
47
|
|
|
38
48
|
## Contributing
|
|
39
49
|
|
|
40
|
-
Bug reports and pull requests are welcome on
|
|
50
|
+
Bug reports and pull requests are welcome on GitLab at https://gitlab.com/lienvdsteen/linter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
41
51
|
|
|
42
52
|
## License
|
|
43
53
|
|
|
@@ -45,4 +55,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
|
45
55
|
|
|
46
56
|
## Code of Conduct
|
|
47
57
|
|
|
48
|
-
Everyone interacting in the Linter project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://
|
|
58
|
+
Everyone interacting in the Linter project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://gitlab.com/lienvdsteen/linter/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
4
|
+
require 'bundler/setup'
|
|
5
|
+
require 'linter'
|
|
5
6
|
require 'pry'
|
|
6
7
|
|
|
7
8
|
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
9
|
# with your gem easier. You can also use a different console, if you like.
|
|
9
10
|
|
|
10
11
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
11
|
-
# require
|
|
12
|
+
# require 'pry'
|
|
12
13
|
# Pry.start
|
|
13
14
|
|
|
14
|
-
require
|
|
15
|
+
require 'irb'
|
|
15
16
|
IRB.start(__FILE__)
|
data/bin/linter
ADDED
|
@@ -78,6 +78,7 @@ masculine_coded:
|
|
|
78
78
|
- fearless
|
|
79
79
|
- fight
|
|
80
80
|
- force
|
|
81
|
+
- guys
|
|
81
82
|
- greedy
|
|
82
83
|
- head-strong
|
|
83
84
|
- headstrong
|
|
@@ -89,12 +90,17 @@ masculine_coded:
|
|
|
89
90
|
- intellect
|
|
90
91
|
- lead
|
|
91
92
|
- logic
|
|
93
|
+
- manpower
|
|
94
|
+
- manning
|
|
95
|
+
- middleman
|
|
96
|
+
- ninja
|
|
92
97
|
- objective
|
|
93
98
|
- opinion
|
|
94
99
|
- outspoken
|
|
95
100
|
- persist
|
|
96
101
|
- principle
|
|
97
102
|
- reckless
|
|
103
|
+
- rockstar
|
|
98
104
|
- self-confiden
|
|
99
105
|
- self-relian
|
|
100
106
|
- self-sufficien
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
problematic:
|
|
2
|
+
- word: spirit animal
|
|
3
|
+
reason: |
|
|
4
|
+
The problem is that spirit animals are an important part of the belief
|
|
5
|
+
system of some cultures and refer to a spirit that “helps guide or protect
|
|
6
|
+
a person on a journey and whose characteristics that person shares or
|
|
7
|
+
embodies.” Referring to something as your spirit animal is cultural
|
|
8
|
+
appropriation. Avoid using it.
|
|
9
|
+
replace_with:
|
|
10
|
+
- kindred spirit
|
|
11
|
+
- raison d'etre
|
|
12
|
+
- word: sherpa
|
|
13
|
+
reason: |
|
|
14
|
+
Unless you mean someone who hails from Tibetan stock and lives in the
|
|
15
|
+
Nepalese Himalayas serving as a porter on mountain-climbing expeditions,
|
|
16
|
+
it is not a Sherpa.
|
|
17
|
+
replace_with:
|
|
18
|
+
- guide
|
|
19
|
+
- coach
|
|
20
|
+
- word: guru
|
|
21
|
+
reason: |
|
|
22
|
+
The word guru comes from Buddhist and Hindu religions and refers to a
|
|
23
|
+
spiritual guide or leader who is held in high esteem. Using the term
|
|
24
|
+
casually in referring to yourself or someone is disrespectful because it
|
|
25
|
+
diminishes the importance of the title and its origins.
|
|
26
|
+
replace_with:
|
|
27
|
+
- doyen
|
|
28
|
+
- virtuoso
|
|
29
|
+
- authority
|
|
30
|
+
- maestro
|
|
31
|
+
- word: ninja
|
|
32
|
+
reason: |
|
|
33
|
+
The term’s origins refer to “a member of a feudal Japanese society of
|
|
34
|
+
mercenary agents, highly trained in martial arts and stealth (ninjutsu),
|
|
35
|
+
who were hired for covert purposes ranging from espionage to sabotage and
|
|
36
|
+
assassination.” People misuse the term to claim expertise in an area.
|
|
37
|
+
replace_with:
|
|
38
|
+
- expert
|
|
39
|
+
- whiz
|
|
40
|
+
- ace
|
|
41
|
+
- word: nazi
|
|
42
|
+
reason: |
|
|
43
|
+
It describes people who were members of the National Socialist German
|
|
44
|
+
Workers’ Party, which controlled Germany from 1933–1945 under Adolf Hitler.
|
|
45
|
+
Using the term casually, as in grammar Nazi or fun Nazi, makes light of
|
|
46
|
+
the horrible atrocities they committed.
|
|
47
|
+
replace_with:
|
|
48
|
+
- boss
|
|
49
|
+
- absolutist
|
|
50
|
+
- word: binge
|
|
51
|
+
reason: |
|
|
52
|
+
We throw around terms like binge-watch and cleaning binge all the time
|
|
53
|
+
when, in fact, the word binge originates from serious eating disorders,
|
|
54
|
+
including Binge Eating Disorder and bulimia, and should be reserved for
|
|
55
|
+
discussions about them. Choosing to watch every episode of The Office in a
|
|
56
|
+
weekend is a choice, whereas bingeing disorders are not a choice and their
|
|
57
|
+
severity shouldn’t be diminished.
|
|
58
|
+
replace_with:
|
|
59
|
+
- indulged
|
|
60
|
+
- spree
|
|
61
|
+
- wallowed
|
|
62
|
+
- satiated
|
|
63
|
+
- word: scalp
|
|
64
|
+
reason: |
|
|
65
|
+
Used as a noun to refer to the top of your head, scalp is fine. It’s when
|
|
66
|
+
it’s used as a verb that we get into dangerous territory.
|
|
67
|
+
|
|
68
|
+
Using it to say someone ripped you off or to infer that you got robbed is
|
|
69
|
+
making light of what was a very gruesome act involving “a part of [the]
|
|
70
|
+
integument [of the upper part of the head] with the accompanying hair,
|
|
71
|
+
severed from the head of an enemy as a sign of victory, as by some North
|
|
72
|
+
American Indians and others during the colonial and frontier periods in
|
|
73
|
+
the US.”
|
|
74
|
+
replace_with:
|
|
75
|
+
- fleeced
|
|
76
|
+
- robbed
|
|
77
|
+
- hustled
|
|
78
|
+
- pulled a fast one
|
|
79
|
+
- word: gyp
|
|
80
|
+
reason: |
|
|
81
|
+
It comes from the word Gypsy, who are Romani people. There are already
|
|
82
|
+
plenty of negative associations with the term gypsy, and using gypped to
|
|
83
|
+
say you got ripped off only perpetuates the negative stereotypes.
|
|
84
|
+
replace_with:
|
|
85
|
+
- ripoff
|
|
86
|
+
- bamboozled
|
|
87
|
+
- shortchanged
|
|
88
|
+
- fraud
|
|
89
|
+
- word: hysterical
|
|
90
|
+
reason: |
|
|
91
|
+
If you find something or someone to be hysterical, meaning funny, that’s
|
|
92
|
+
OK. If you’re calling someone’s actions hysterical because they’re being
|
|
93
|
+
emotional, then you may want to reconsider.
|
|
94
|
+
|
|
95
|
+
Far too often women are dubbed hysterical for being outspoken or showing
|
|
96
|
+
their feelings, and that wades into problematic, sexist territory due to
|
|
97
|
+
the history of the term.
|
|
98
|
+
|
|
99
|
+
Hysterical’s earliest meaning was “of, relating to, or characterized by
|
|
100
|
+
hysteria,” and while we now think of hysteria as irrational panic, it was,
|
|
101
|
+
for centuries, a medical diagnosis. Hysteria comes from the Greek
|
|
102
|
+
hysterikós, which means “suffering in the womb.”
|
|
103
|
+
|
|
104
|
+
So, yeah, the ancient Greeks believed that when a woman was behaving
|
|
105
|
+
irrationally—or in a way that they considered to be irrational—it was
|
|
106
|
+
because her uterus was literally wandering around her body causing trouble
|
|
107
|
+
(Kory Stamper, “What It Really Means To Call A Woman Hysterical“).
|
|
108
|
+
replace_with:
|
|
109
|
+
- intense
|
|
110
|
+
- impassioned
|
|
111
|
+
- piercing
|
|
112
|
+
- vehement
|
|
113
|
+
- word: lame
|
|
114
|
+
reason: |
|
|
115
|
+
"Lame" was originally used in reference to people with reduced mobility
|
|
116
|
+
due to physical disability. The word is now tossed around everywhere to
|
|
117
|
+
mean "uncool" and "unappealing." Disability rights activists have long
|
|
118
|
+
called for the word to phase out. We have a responsibility to respect that.
|
|
119
|
+
replace_with:
|
|
120
|
+
- old hat
|
|
121
|
+
- hackneyed
|
|
122
|
+
- stodgy
|
|
123
|
+
- jejune
|
|
124
|
+
- pedestrian
|
|
125
|
+
- humdrum
|
|
126
|
+
- word: retarded
|
|
127
|
+
reason: |
|
|
128
|
+
The term "mental retardation" is a stale, clinical term once used to label
|
|
129
|
+
what we now call intellectual disabilities. Using the term to mean "stupid"
|
|
130
|
+
devalues those with intellectual disabilities, which should make you
|
|
131
|
+
question your word choice.
|
|
132
|
+
replace_with:
|
|
133
|
+
- If you are using it as a descriptor for a person with an intellectual disability in a context where such a descriptor is necessary, you could replace it with a term that does not have the same derogatory connotation, or the name of the actual disability if relevant.
|
|
134
|
+
- If you are using it to insult someone (e.g. "You're such a retard") then don't.
|
data/lib/linter.rb
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'linter/version'
|
|
4
|
+
require_relative 'linter/base_association'
|
|
5
|
+
require_relative 'linter/gender_association'
|
|
6
|
+
require_relative 'linter/pronoun_association'
|
|
7
|
+
require_relative 'linter/cli'
|
|
8
|
+
require_relative 'linter/misused_words'
|
|
4
9
|
|
|
5
10
|
require 'yaml'
|
|
11
|
+
require 'colorize'
|
|
12
|
+
require 'ostruct'
|
|
6
13
|
|
|
7
14
|
module Linter
|
|
8
15
|
class Error < StandardError; end
|
|
16
|
+
|
|
17
|
+
class << self
|
|
18
|
+
def cli_analyze(file_name)
|
|
19
|
+
Linter::CLI.analyze(file_name)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
9
22
|
end
|
|
@@ -1,18 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Linter
|
|
2
4
|
class BaseAssociation
|
|
3
|
-
|
|
5
|
+
def self.analyze(text)
|
|
6
|
+
result = OpenStruct.new(
|
|
7
|
+
feminine_coded_word_counts: {},
|
|
8
|
+
masculine_coded_word_counts: {},
|
|
9
|
+
trend: ''
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
wordlists['feminine_coded'].each do |word|
|
|
13
|
+
result.feminine_coded_word_counts.merge!(word_count(text, word))
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
wordlists['masculine_coded'].each do |word|
|
|
17
|
+
result.masculine_coded_word_counts.merge!(word_count(text, word))
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
result.trend = calculate_trend(result)
|
|
21
|
+
result
|
|
22
|
+
end
|
|
4
23
|
|
|
5
24
|
def self.word_count(text, word)
|
|
6
|
-
|
|
25
|
+
if self::FULL_WORD
|
|
26
|
+
regex = /\b#{word}\b/i
|
|
27
|
+
else
|
|
28
|
+
regex = /\b(#{word}\w*)\b/i
|
|
29
|
+
end
|
|
7
30
|
matches = text.scan(regex)
|
|
8
31
|
return {} unless matches.any?
|
|
9
32
|
|
|
10
33
|
# Use Enumerable#tally with Ruby 2.7
|
|
11
34
|
matches
|
|
12
35
|
.flatten
|
|
13
|
-
.map
|
|
36
|
+
.map(&:downcase)
|
|
14
37
|
.group_by { |v| v }
|
|
15
|
-
.
|
|
38
|
+
.transform_values(&:size)
|
|
16
39
|
.to_h
|
|
17
40
|
end
|
|
18
41
|
end
|
data/lib/linter/cli.rb
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Linter
|
|
4
|
+
class CLI
|
|
5
|
+
def self.analyze(file_name)
|
|
6
|
+
# first read the file
|
|
7
|
+
text = File.read(file_name)
|
|
8
|
+
result = Linter::GenderAssociation.analyze(text)
|
|
9
|
+
puts result.inspect.colorize(:red)
|
|
10
|
+
result = Linter::PronounAssociation.analyze(text)
|
|
11
|
+
puts result.inspect.colorize(:red)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -1,23 +1,8 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Linter
|
|
2
4
|
class GenderAssociation < BaseAssociation
|
|
3
|
-
|
|
4
|
-
result = OpenStruct.new(
|
|
5
|
-
feminine_coded_word_counts: {},
|
|
6
|
-
masculine_coded_word_counts: {},
|
|
7
|
-
trend: ''
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
wordlists['feminine_coded'].each do |word|
|
|
11
|
-
result.feminine_coded_word_counts.merge!(word_count(text, word))
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
wordlists['masculine_coded'].each do |word|
|
|
15
|
-
result.masculine_coded_word_counts.merge!(word_count(text, word))
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
result.trend = calculate_trend(result)
|
|
19
|
-
result
|
|
20
|
-
end
|
|
5
|
+
FULL_WORD = false
|
|
21
6
|
|
|
22
7
|
private
|
|
23
8
|
|
|
@@ -34,7 +19,7 @@ module Linter
|
|
|
34
19
|
'feminine-coded'
|
|
35
20
|
when 3..Float::INFINITY
|
|
36
21
|
'strongly feminine-coded'
|
|
37
|
-
when -Float::INFINITY
|
|
22
|
+
when -Float::INFINITY..-3
|
|
38
23
|
'strongly masculine-coded'
|
|
39
24
|
else
|
|
40
25
|
'masculine-coded'
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Linter
|
|
4
|
+
class MisusedWords
|
|
5
|
+
def self.analyze(text)
|
|
6
|
+
result = OpenStruct.new(
|
|
7
|
+
misused_words: [],
|
|
8
|
+
trend: ''
|
|
9
|
+
)
|
|
10
|
+
wordlists.dig('problematic').each do |problematic_word|
|
|
11
|
+
word = problematic_word['word']
|
|
12
|
+
regex = /\b#{word}\b/i
|
|
13
|
+
result.misused_words << problematic_word if text.scan(regex).any?
|
|
14
|
+
end
|
|
15
|
+
result
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def self.wordlists
|
|
21
|
+
file_path = File.join(__dir__,'../../data/misused_wordlist.yml')
|
|
22
|
+
@wordlists ||= YAML.load_file(file_path)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Linter
|
|
4
|
+
class PronounAssociation < BaseAssociation
|
|
5
|
+
FULL_WORD = true
|
|
6
|
+
|
|
7
|
+
def self.wordlists
|
|
8
|
+
file_path = File.join(__dir__,'../../data/pronoun_association_wordlist.yml')
|
|
9
|
+
@wordlists ||= YAML.load_file(file_path)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def self.calculate_trend(result)
|
|
15
|
+
return 'masculine-coded' if result.masculine_coded_word_counts.values.sum.positive?
|
|
16
|
+
|
|
17
|
+
return 'feminine-coded' if result.feminine_coded_word_counts.values.sum.positive?
|
|
18
|
+
|
|
19
|
+
'neutral'
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
data/lib/linter/version.rb
CHANGED
data/linter.gemspec
CHANGED
|
@@ -1,43 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
-
require
|
|
3
|
+
require 'linter/version'
|
|
5
4
|
|
|
6
5
|
Gem::Specification.new do |spec|
|
|
7
|
-
spec.name =
|
|
6
|
+
spec.name = 'linter'
|
|
8
7
|
spec.version = Linter::VERSION
|
|
9
|
-
spec.authors = [
|
|
10
|
-
spec.email = [
|
|
8
|
+
spec.authors = ['lien van den steen']
|
|
9
|
+
spec.email = ['lienvandensteen@gmail.com']
|
|
11
10
|
|
|
12
11
|
spec.summary = 'Library to check a text for gender coded language'
|
|
13
12
|
# spec.description = %q{TODO: Write a longer description or delete this line.}
|
|
14
|
-
spec.homepage =
|
|
15
|
-
spec.license =
|
|
13
|
+
spec.homepage = 'https://gitlab.com/lienvdsteen/linter'
|
|
14
|
+
spec.license = 'MIT'
|
|
16
15
|
|
|
17
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the
|
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the "allowed_push_host"
|
|
18
17
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
19
18
|
if spec.respond_to?(:metadata)
|
|
20
|
-
# spec.metadata["allowed_push_host"] = "TODO: Set to
|
|
19
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to "http://mygemserver.com"
|
|
21
20
|
|
|
22
|
-
spec.metadata[
|
|
23
|
-
spec.metadata[
|
|
24
|
-
# spec.metadata[
|
|
21
|
+
spec.metadata['homepage_uri'] = 'https://gitlab.com/lienvdsteen/linter'
|
|
22
|
+
spec.metadata['source_code_uri'] = 'https://gitlab.com/lienvdsteen/linter'
|
|
23
|
+
# spec.metadata['changelog_uri'] = 'TODO: Put your gem's CHANGELOG.md URL here.'
|
|
25
24
|
else
|
|
26
|
-
raise
|
|
27
|
-
|
|
25
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
|
26
|
+
'public gem pushes.'
|
|
28
27
|
end
|
|
29
28
|
|
|
30
29
|
# Specify which files should be added to the gem when it is released.
|
|
31
30
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
31
|
+
# Use expand_path(__dir__) instead of expand_path('..', __FILE__).
|
|
32
32
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
33
33
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
34
34
|
end
|
|
35
|
-
spec.bindir =
|
|
35
|
+
spec.bindir = 'exe'
|
|
36
36
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
37
|
-
spec.require_paths = [
|
|
37
|
+
spec.require_paths = ['lib']
|
|
38
38
|
|
|
39
|
-
spec.add_development_dependency
|
|
40
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
|
41
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
|
39
|
+
spec.add_development_dependency 'bundler', '~> 1.17'
|
|
42
40
|
spec.add_development_dependency 'pry', '~> 0.13'
|
|
41
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
42
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
43
|
+
spec.add_development_dependency 'rubocop', '~> 0.85'
|
|
44
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 1.39'
|
|
45
|
+
|
|
46
|
+
spec.add_dependency('colorize', '~> 0.8')
|
|
43
47
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: linter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- lien van den steen
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-06-
|
|
11
|
+
date: 2020-06-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -24,6 +24,20 @@ dependencies:
|
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '1.17'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: pry
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0.13'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0.13'
|
|
27
41
|
- !ruby/object:Gem::Dependency
|
|
28
42
|
name: rake
|
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -53,19 +67,47 @@ dependencies:
|
|
|
53
67
|
- !ruby/object:Gem::Version
|
|
54
68
|
version: '3.0'
|
|
55
69
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
70
|
+
name: rubocop
|
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
|
58
72
|
requirements:
|
|
59
73
|
- - "~>"
|
|
60
74
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '0.
|
|
75
|
+
version: '0.85'
|
|
62
76
|
type: :development
|
|
63
77
|
prerelease: false
|
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
79
|
requirements:
|
|
66
80
|
- - "~>"
|
|
67
81
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '0.
|
|
82
|
+
version: '0.85'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: rubocop-rspec
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '1.39'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '1.39'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: colorize
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0.8'
|
|
104
|
+
type: :runtime
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0.8'
|
|
69
111
|
description:
|
|
70
112
|
email:
|
|
71
113
|
- lienvandensteen@gmail.com
|
|
@@ -76,6 +118,8 @@ files:
|
|
|
76
118
|
- ".gitignore"
|
|
77
119
|
- ".gitlab-ci.yml"
|
|
78
120
|
- ".rspec"
|
|
121
|
+
- ".rubocop.yml"
|
|
122
|
+
- ".rubocop_todo.yml"
|
|
79
123
|
- ".ruby-version"
|
|
80
124
|
- ".travis.yml"
|
|
81
125
|
- CODE_OF_CONDUCT.md
|
|
@@ -85,11 +129,17 @@ files:
|
|
|
85
129
|
- README.md
|
|
86
130
|
- Rakefile
|
|
87
131
|
- bin/console
|
|
132
|
+
- bin/linter
|
|
88
133
|
- bin/setup
|
|
89
134
|
- data/gender_association_wordlist.yml
|
|
135
|
+
- data/misused_wordlist.yml
|
|
136
|
+
- data/pronoun_association_wordlist.yml
|
|
90
137
|
- lib/linter.rb
|
|
91
138
|
- lib/linter/base_association.rb
|
|
139
|
+
- lib/linter/cli.rb
|
|
92
140
|
- lib/linter/gender_association.rb
|
|
141
|
+
- lib/linter/misused_words.rb
|
|
142
|
+
- lib/linter/pronoun_association.rb
|
|
93
143
|
- lib/linter/version.rb
|
|
94
144
|
- linter.gemspec
|
|
95
145
|
homepage: https://gitlab.com/lienvdsteen/linter
|