linter 0.1.4 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '08b1ff0198e0f6f389ee13707020581608ac96eadff6cb34a0e47821aa6d03d6'
4
- data.tar.gz: b9d3e3b3d42cb76e7df568da374488b0c8047d19cc1985f38a34021e5720fd22
3
+ metadata.gz: a80c5734dad74a7737293169a71422fc05f45e75662615ee1b135e4efd96332e
4
+ data.tar.gz: cadc9e3c07b8fde011e5a0688efc9d309082d7a0f587a8d6ef616da25c3bd311
5
5
  SHA512:
6
- metadata.gz: 1a9e8cc02d838eac96ab0952f009d0281104fd63ee25e8846a76143f56be0d64a8704abb8a08d579b2009fb010f94e7914ef2395457f05861d1d734992cf24e6
7
- data.tar.gz: 9b857bd50998ef0e71696c78fe77e89262545c94e02b8f67008a9f87d46887bc6387e08feda977be6f4c1829c05ff1ea5212207b0234217004fee17491735559
6
+ metadata.gz: b36c820823c1e67f49ce474ad589665d4e98fe4c8256656ede53b203de79137a1749e1c9d5acabf056d923b3c1db02d663bfdb075bf403656eb757d15b9e849e
7
+ data.tar.gz: 360c60b81bf244368b9a9e5421b641c3bd34d16436b252342aadd64c85eeae39601ccc3d44f0efe03521aa8db23770b5ee4722e75293f78b0a1639993507a9cd
@@ -5,3 +5,14 @@ rspec:
5
5
  script:
6
6
  - bundle install
7
7
  - bundle exec rspec
8
+
9
+ rubocop:
10
+ stage: test
11
+ only:
12
+ - merge_requests
13
+ script:
14
+ - bundle install
15
+ - bundle exec rubocop
16
+
17
+ include:
18
+ template: Dependency-Scanning.gitlab-ci.yml
@@ -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
@@ -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
@@ -1,6 +1,6 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ source 'https://rubygems.org'
4
4
 
5
5
  group :development do
6
6
  gem 'pry'
@@ -1,21 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- linter (0.1.4)
4
+ linter (0.1.9)
5
5
  colorize (~> 0.8)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ ast (2.4.0)
10
11
  coderay (1.1.3)
11
12
  colorize (0.8.1)
12
13
  diff-lcs (1.3)
13
14
  method_source (1.0.0)
15
+ parallel (1.19.1)
16
+ parser (2.7.1.3)
17
+ ast (~> 2.4.0)
14
18
  pry (0.13.1)
15
19
  coderay (~> 1.1)
16
20
  method_source (~> 1.0)
21
+ rainbow (3.0.0)
17
22
  rake (10.5.0)
18
23
  rb-readline (0.5.5)
24
+ regexp_parser (1.7.0)
25
+ rexml (3.2.4)
19
26
  rspec (3.9.0)
20
27
  rspec-core (~> 3.9.0)
21
28
  rspec-expectations (~> 3.9.0)
@@ -29,6 +36,21 @@ GEM
29
36
  diff-lcs (>= 1.2.0, < 2.0)
30
37
  rspec-support (~> 3.9.0)
31
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)
32
54
 
33
55
  PLATFORMS
34
56
  ruby
@@ -40,6 +62,8 @@ DEPENDENCIES
40
62
  rake (~> 10.0)
41
63
  rb-readline
42
64
  rspec (~> 3.0)
65
+ rubocop (~> 0.85)
66
+ rubocop-rspec (~> 1.39)
43
67
 
44
68
  BUNDLED WITH
45
69
  1.17.2
data/README.md CHANGED
@@ -23,15 +23,34 @@ Or install it yourself as:
23
23
 
24
24
  ## Usage
25
25
 
26
+ If you want to perform all of the inclusiveness checks we currently offer, you can run:
27
+
28
+ ```ruby
29
+ text = 'your text here'
30
+ response = Linter.analyze(text)
31
+ ```
32
+
33
+ You can also use the checks individually:
34
+
26
35
  ```ruby
27
36
  text = 'Collaborate closely with the manager. Analytics all the way.'
28
37
  Linter::GenderAssociation.analyze(text)
29
38
  # #<OpenStruct feminine_coded_word_counts={"collaborate" => 1}, masculine_coded_word_counts={"analytics" => 1}, trend="neutral">
39
+
30
40
  text = 'He was working at the bar.'
31
41
  Linter::PronounAssociation.analyze(text)
42
+ #<OpenStruct trend="masculine-coded", feminine_coded_word_counts={}, masculine_coded_word_counts={"he"=>1}>
43
+
44
+ text = 'You are my spirit animal'
45
+ Linter::MisusedWords.analyze(text)
46
+ #<OpenStruct misused_words=[{"word"=>"spirit animal", "reason"=>"The problem is that spirit animals are an important part of the belief\nsystem of some cultures and refer to a spirit that “helps guide or protect\na person on a journey and whose characteristics that person shares or\nembodies.” Referring to something as your spirit animal is cultural\nappropriation. Avoid using it.\n", "replace_with"=>["kindred spirit", "raison d'etre"]}], trend="">
32
47
  ```
33
48
 
34
- ## CLI Usage
49
+ You'll notice that the `association` checks do a comparison of the whole text and will determine a _trend_ for your text. When your text uses a lot of
50
+ masculine-coded language, the text will be marked as such. The regular checks (like `MisusedWords`) will return all the misused words, a reason why
51
+ and if possible, we provide some suggestions to replace the word.
52
+
53
+ ## CLI Usage -> In development
35
54
 
36
55
  ```console
37
56
  linter example.md
@@ -47,7 +66,13 @@ To install this gem onto your local machine, run `bundle exec rake install`.
47
66
 
48
67
  ## Contributing
49
68
 
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.
69
+ Bug reports and merge 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.
70
+
71
+ We are looking for different types of contributions:
72
+ - additional checks
73
+ - adding/editing words to the existing wordlists
74
+ - support for other languages besides English
75
+ - ...
51
76
 
52
77
  ## License
53
78
 
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
@@ -1,15 +1,16 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "linter"
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 "pry"
12
+ # require 'pry'
12
13
  # Pry.start
13
14
 
14
- require "irb"
15
+ require 'irb'
15
16
  IRB.start(__FILE__)
data/bin/linter CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
- require_relative "../lib/linter"
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../lib/linter'
3
5
 
4
6
  Linter::CLI.analyze(ARGV[0])
@@ -1,106 +1,113 @@
1
- feminine_coded:
2
- - agree
3
- - affectionate
4
- - child*
5
- - cheer
6
- - collab
7
- - commit
8
- - communal
9
- - compassion
10
- - connect
11
- - considerate
12
- - cooperat
13
- - co-operat
14
- - depend
15
- - emotiona
16
- - empath
17
- - feel
18
- - flatterable
19
- - gentle
20
- - honest
21
- - interpersonal
22
- - interdependen
23
- - interpersona
24
- - inter-personal
25
- - inter-dependen
26
- - inter-persona
27
- - kind
28
- - kinship
29
- - loyal
30
- - modesty
31
- - nag
32
- - nurtur
33
- - pleasant
34
- - polite
35
- - quiet*
36
- - respon
37
- - sensitiv
38
- - submissive
39
- - support
40
- - sympath
41
- - tender
42
- - together
43
- - trust
44
- - understand
45
- - warm
46
- - whin
47
- - enthusias
48
- - inclusive
49
- - yield
50
- - share
51
- - sharin
1
+ words:
2
+ feminine_coded:
3
+ - agree
4
+ - affectionate
5
+ - child*
6
+ - cheer
7
+ - collab
8
+ - commit
9
+ - communal
10
+ - compassion
11
+ - connect
12
+ - considerate
13
+ - cooperat
14
+ - co-operat
15
+ - depend
16
+ - emotiona
17
+ - empath
18
+ - feel
19
+ - flatterable
20
+ - gentle
21
+ - honest
22
+ - interpersonal
23
+ - interdependen
24
+ - interpersona
25
+ - inter-personal
26
+ - inter-dependen
27
+ - inter-persona
28
+ - kind
29
+ - kinship
30
+ - loyal
31
+ - modesty
32
+ - nag
33
+ - nurtur
34
+ - pleasant
35
+ - polite
36
+ - quiet*
37
+ - respon
38
+ - sensitiv
39
+ - submissive
40
+ - support
41
+ - sympath
42
+ - tender
43
+ - together
44
+ - trust
45
+ - understand
46
+ - warm
47
+ - whin
48
+ - enthusias
49
+ - inclusive
50
+ - yield
51
+ - share
52
+ - sharin
52
53
 
53
- masculine_coded:
54
- - active
55
- - adventurous
56
- - aggress
57
- - ambitio
58
- - analytics
59
- - analy
60
- - assert
61
- - athlet
62
- - autonom
63
- - battle
64
- - boast
65
- - challeng
66
- - champion
67
- - compet
68
- - confident
69
- - courag
70
- - decid
71
- - decision
72
- - decisive
73
- - defend
74
- - determin
75
- - domina
76
- - dominant
77
- - driven
78
- - fearless
79
- - fight
80
- - force
81
- - greedy
82
- - head-strong
83
- - headstrong
84
- - hierarch
85
- - hostil
86
- - impulsive
87
- - independen
88
- - individual
89
- - intellect
90
- - lead
91
- - logic
92
- - objective
93
- - opinion
94
- - outspoken
95
- - persist
96
- - principle
97
- - reckless
98
- - self-confiden
99
- - self-relian
100
- - self-sufficien
101
- - selfconfiden
102
- - selfrelian
103
- - selfsufficien
104
- - stubborn
105
- - superior
106
- - unreasonab
54
+ masculine_coded:
55
+ - active
56
+ - adventurous
57
+ - aggress
58
+ - ambitio
59
+ - analytics
60
+ - analy
61
+ - assert
62
+ - athlet
63
+ - autonom
64
+ - battle
65
+ - boast
66
+ - challeng
67
+ - champion
68
+ - compet
69
+ - confident
70
+ - courag
71
+ - decid
72
+ - decision
73
+ - decisive
74
+ - defend
75
+ - determin
76
+ - domina
77
+ - dominant
78
+ - driven
79
+ - fearless
80
+ - fight
81
+ - force
82
+ - guys
83
+ - greedy
84
+ - head-strong
85
+ - headstrong
86
+ - hierarch
87
+ - hostil
88
+ - impulsive
89
+ - independen
90
+ - individual
91
+ - intellect
92
+ - lead
93
+ - logic
94
+ - manpower
95
+ - manning
96
+ - middleman
97
+ - ninja
98
+ - objective
99
+ - opinion
100
+ - outspoken
101
+ - persist
102
+ - principle
103
+ - reckless
104
+ - rockstar
105
+ - self-confiden
106
+ - self-relian
107
+ - self-sufficien
108
+ - selfconfiden
109
+ - selfrelian
110
+ - selfsufficien
111
+ - stubborn
112
+ - superior
113
+ - unreasonab
@@ -0,0 +1,26 @@
1
+ words:
2
+ growth_coded:
3
+ - striving
4
+ - driven
5
+ - highly motivated
6
+ - improvement
7
+ - learn
8
+ - strive
9
+ - grow
10
+ - persevere
11
+ - determined
12
+
13
+ fixed_coded:
14
+ - est
15
+ - brightest
16
+ - smart
17
+ - performer
18
+ - intelligent
19
+ - rockstar
20
+ - superhero
21
+ - genius
22
+ - expert
23
+ - brilliant
24
+ - natural
25
+ - talent
26
+ - overachieve
@@ -0,0 +1,164 @@
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.
135
+ - word: blacklist
136
+ reason: |
137
+ Black is too often used in a negative context (with the opposite being
138
+ referred to as white). Please consider using alternatives when they convey
139
+ the same meaning.
140
+ replace_with:
141
+ - blocklist
142
+ - word: whitelist
143
+ reason: |
144
+ Black & white are often used in contexts where white is the positive item,
145
+ and black the negative item. Please consider using alternatives when they
146
+ convey the same meaning.
147
+ replace_with:
148
+ - allowlist
149
+ - word: master
150
+ reason: |
151
+ Master (in context of master/slave) is often used in computer terminology
152
+ when leader/follower, or primary/replica are as meaningful and don't have
153
+ a connotation of slavery.
154
+ replace_with:
155
+ - leader
156
+ - primary
157
+ - word: slave
158
+ reason: |
159
+ Master (in context of master/slave) is often used in computer terminology
160
+ when leader/follower, or primary/replica are as meaningful and don't have
161
+ a connotation of slavery.
162
+ replace_with:
163
+ - follower
164
+ - replica
@@ -1,11 +1,12 @@
1
- feminine_coded:
2
- - she
3
- - her
4
- - hers
5
- - herself
1
+ words:
2
+ feminine_coded:
3
+ - she
4
+ - her
5
+ - hers
6
+ - herself
6
7
 
7
- masculine_coded:
8
- - he
9
- - his
10
- - him
11
- - himself
8
+ masculine_coded:
9
+ - he
10
+ - his
11
+ - him
12
+ - himself
@@ -1,19 +1,27 @@
1
- require_relative "linter/version"
2
- require_relative "linter/base_association"
3
- require_relative "linter/gender_association"
4
- require_relative "linter/pronoun_association"
5
- require_relative "linter/cli"
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'
9
+ require_relative 'linter/mindset_association'
6
10
 
7
11
  require 'yaml'
8
12
  require 'colorize'
9
- require "ostruct"
13
+ require 'ostruct'
10
14
 
11
15
  module Linter
12
16
  class Error < StandardError; end
13
17
 
14
18
  class << self
15
- def cli_analyze(file_name)
16
- Linter::CLI.analyze(file_name)
19
+ def analyze(text)
20
+ {
21
+ gender_association_analysis: Linter::GenderAssociation.analyze(text),
22
+ pronoun_analysis: Linter::PronounAssociation.analyze(text),
23
+ misused_words_analysis: Linter::MisusedWords.analyze(text)
24
+ }
17
25
  end
18
26
  end
19
27
  end
@@ -1,26 +1,22 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Linter
2
4
  class BaseAssociation
3
5
  def self.analyze(text)
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
6
+ result = OpenStruct.new(trend: '')
13
7
 
14
- wordlists['masculine_coded'].each do |word|
15
- result.masculine_coded_word_counts.merge!(word_count(text, word))
8
+ wordlists.dig('words').each do |key, words|
9
+ word_count_key = "#{key}_word_counts".to_sym
10
+ result[word_count_key] = {}
11
+ words.each do |word|
12
+ result.send(word_count_key).merge!(word_count(text, word))
13
+ end
16
14
  end
17
15
 
18
16
  result.trend = calculate_trend(result)
19
17
  result
20
18
  end
21
19
 
22
- private
23
-
24
20
  def self.word_count(text, word)
25
21
  if self::FULL_WORD
26
22
  regex = /\b#{word}\b/i
@@ -33,9 +29,9 @@ module Linter
33
29
  # Use Enumerable#tally with Ruby 2.7
34
30
  matches
35
31
  .flatten
36
- .map { |word| word.downcase }
32
+ .map(&:downcase)
37
33
  .group_by { |v| v }
38
- .map { |k, v| [k, v.size] }
34
+ .transform_values(&:size)
39
35
  .to_h
40
36
  end
41
37
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Linter
2
4
  class CLI
3
5
  def self.analyze(file_name)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Linter
2
4
  class GenderAssociation < BaseAssociation
3
5
  FULL_WORD = false
@@ -17,7 +19,7 @@ module Linter
17
19
  'feminine-coded'
18
20
  when 3..Float::INFINITY
19
21
  'strongly feminine-coded'
20
- when -Float::INFINITY..0
22
+ when -Float::INFINITY..-3
21
23
  'strongly masculine-coded'
22
24
  else
23
25
  'masculine-coded'
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Linter
4
+ class MindsetAssociation < BaseAssociation
5
+ USE_FOR_JOB_ADS = true
6
+ FULL_WORD = false
7
+
8
+ def self.wordlists
9
+ file_path = File.join(__dir__, '../../data/mindset_wordlist.yml')
10
+ @wordlists ||= YAML.load_file(file_path)
11
+ end
12
+
13
+ def self.calculate_trend(result)
14
+ case result.growth_coded_word_counts.values.sum - result.fixed_coded_word_counts.values.sum
15
+ when 0
16
+ 'neutral'
17
+ when 1..3
18
+ 'growth-coded'
19
+ when 3..Float::INFINITY
20
+ 'strongly growth-coded'
21
+ when -Float::INFINITY..-3
22
+ 'strongly fixed-coded'
23
+ else
24
+ 'fixed-coded'
25
+ end
26
+ end
27
+ end
28
+ end
@@ -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
@@ -1,18 +1,22 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Linter
2
4
  class PronounAssociation < BaseAssociation
3
5
  FULL_WORD = true
4
6
 
5
- private
6
-
7
7
  def self.wordlists
8
8
  file_path = File.join(__dir__,'../../data/pronoun_association_wordlist.yml')
9
9
  @wordlists ||= YAML.load_file(file_path)
10
10
  end
11
11
 
12
+ private
13
+
12
14
  def self.calculate_trend(result)
13
15
  return 'masculine-coded' if result.masculine_coded_word_counts.values.sum.positive?
16
+
14
17
  return 'feminine-coded' if result.feminine_coded_word_counts.values.sum.positive?
15
- return 'neutral'
18
+
19
+ 'neutral'
16
20
  end
17
21
  end
18
22
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Linter
2
- VERSION = "0.1.4"
4
+ VERSION = '0.1.9'
3
5
  end
@@ -1,44 +1,47 @@
1
- lib = File.expand_path("../lib", __FILE__)
1
+ lib = File.expand_path('../lib', __FILE__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require "linter/version"
3
+ require 'linter/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = "linter"
6
+ spec.name = 'linter'
7
7
  spec.version = Linter::VERSION
8
- spec.authors = ["lien van den steen"]
9
- spec.email = ["lienvandensteen@gmail.com"]
8
+ spec.authors = ['lien van den steen']
9
+ spec.email = ['lienvandensteen@gmail.com']
10
10
 
11
11
  spec.summary = 'Library to check a text for gender coded language'
12
12
  # spec.description = %q{TODO: Write a longer description or delete this line.}
13
- spec.homepage = "https://gitlab.com/lienvdsteen/linter"
14
- spec.license = "MIT"
13
+ spec.homepage = 'https://gitlab.com/lienvdsteen/linter'
14
+ spec.license = 'MIT'
15
15
 
16
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the "allowed_push_host"
17
17
  # to allow pushing to a single host or delete this section to allow pushing to any host.
18
18
  if spec.respond_to?(:metadata)
19
- # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
19
+ # spec.metadata["allowed_push_host"] = "TODO: Set to "http://mygemserver.com"
20
20
 
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."
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.'
24
24
  else
25
- raise "RubyGems 2.0 or newer is required to protect against " \
26
- "public gem pushes."
25
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
26
+ 'public gem pushes.'
27
27
  end
28
28
 
29
29
  # Specify which files should be added to the gem when it is released.
30
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__).
31
32
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
32
33
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
33
34
  end
34
- spec.bindir = "exe"
35
+ spec.bindir = 'exe'
35
36
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
- spec.require_paths = ["lib"]
37
+ spec.require_paths = ['lib']
37
38
 
38
- spec.add_development_dependency "bundler", "~> 1.17"
39
- spec.add_development_dependency "rake", "~> 10.0"
40
- spec.add_development_dependency "rspec", "~> 3.0"
39
+ spec.add_development_dependency 'bundler', '~> 1.17'
41
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'
42
45
 
43
46
  spec.add_dependency('colorize', '~> 0.8')
44
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
4
+ version: 0.1.9
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-06 00:00:00.000000000 Z
11
+ date: 2020-06-16 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,33 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: '3.0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: pry
70
+ name: rubocop
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '0.13'
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.13'
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'
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: colorize
71
99
  requirement: !ruby/object:Gem::Requirement
@@ -90,6 +118,8 @@ files:
90
118
  - ".gitignore"
91
119
  - ".gitlab-ci.yml"
92
120
  - ".rspec"
121
+ - ".rubocop.yml"
122
+ - ".rubocop_todo.yml"
93
123
  - ".ruby-version"
94
124
  - ".travis.yml"
95
125
  - CODE_OF_CONDUCT.md
@@ -102,11 +132,15 @@ files:
102
132
  - bin/linter
103
133
  - bin/setup
104
134
  - data/gender_association_wordlist.yml
135
+ - data/mindset_wordlist.yml
136
+ - data/misused_wordlist.yml
105
137
  - data/pronoun_association_wordlist.yml
106
138
  - lib/linter.rb
107
139
  - lib/linter/base_association.rb
108
140
  - lib/linter/cli.rb
109
141
  - lib/linter/gender_association.rb
142
+ - lib/linter/mindset_association.rb
143
+ - lib/linter/misused_words.rb
110
144
  - lib/linter/pronoun_association.rb
111
145
  - lib/linter/version.rb
112
146
  - linter.gemspec