linter 0.1.3 → 0.1.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 132bd553ebe8639ffa00c6c6662655a9d3356c54676630dd70696b844ab31f94
4
- data.tar.gz: 6bbeac0a7ac6394dedeba49290344f466063c46a30651bd8d918d75e7ea7937c
3
+ metadata.gz: 0d37fc2c12261ce9fc63abee6bc787ae37fceb65591e8d77daf4d363d3b5e237
4
+ data.tar.gz: 72fe17fd2674c5fb5b7f280c4b122f79e0b5f28d30bb054cee844d348392bf67
5
5
  SHA512:
6
- metadata.gz: 3bbd652dde4ac9056e2082e21b376952787c6881885d5059a36ee3a8e0a5bbf2f0becc0b451dc92bbd2fe5d4439b0c2e0f83d2da1289d56f07542cbd964c289f
7
- data.tar.gz: 31c8988bfc69608a44795104df41384699448b4d9a1c2ebb932d9cae854240dc27741eec549386672834df60c60f766ee41231e3908b1bc8e3ae2c8b0af81678
6
+ metadata.gz: 4f3c1029a82a2e886080341d60573a1a89397ae6561254ff07d06e7a2100adc7ee39efdc8dd47318bee85a1342797b7c3263d1059ff0bac8bd11c125e46ea937
7
+ data.tar.gz: 914afdd6cf0a6d3a2d1f1e7f409fa754c8d7238079404ebb29dbea626ae12672e60fe75d1699d446cc0cae8b631f7d0e887a84207d6c1e156378a453f0d104b1
@@ -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,19 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- linter (0.1.2)
4
+ linter (0.1.8)
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
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
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__)
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../lib/linter'
5
+
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,10 +1,23 @@
1
- require "linter/version"
2
- require "linter/base_association"
3
- require "linter/gender_association"
4
- require "linter/pronoun_association"
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'
5
10
 
6
11
  require 'yaml'
12
+ require 'colorize'
13
+ require 'ostruct'
7
14
 
8
15
  module Linter
9
16
  class Error < StandardError; end
17
+
18
+ class << self
19
+ def cli_analyze(file_name)
20
+ Linter::CLI.analyze(file_name)
21
+ end
22
+ end
10
23
  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
@@ -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,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.fixed_coded_word_counts.values.sum - result.growth_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.3"
4
+ VERSION = '0.1.8'
3
5
  end
@@ -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 "linter/version"
3
+ require 'linter/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "linter"
6
+ spec.name = 'linter'
8
7
  spec.version = Linter::VERSION
9
- spec.authors = ["lien van den steen"]
10
- spec.email = ["lienvandensteen@gmail.com"]
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 = "https://gitlab.com/lienvdsteen/linter"
15
- spec.license = "MIT"
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 'allowed_push_host'
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 'http://mygemserver.com'"
19
+ # spec.metadata["allowed_push_host"] = "TODO: Set to "http://mygemserver.com"
21
20
 
22
- spec.metadata["homepage_uri"] = 'https://gitlab.com/lienvdsteen/linter'
23
- spec.metadata["source_code_uri"] = "https://gitlab.com/lienvdsteen/linter"
24
- # 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.'
25
24
  else
26
- raise "RubyGems 2.0 or newer is required to protect against " \
27
- "public gem pushes."
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 = "exe"
35
+ spec.bindir = 'exe'
36
36
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
- spec.require_paths = ["lib"]
37
+ spec.require_paths = ['lib']
38
38
 
39
- spec.add_development_dependency "bundler", "~> 1.17"
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.3
4
+ version: 0.1.8
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-04 00:00:00.000000000 Z
11
+ date: 2020-06-11 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: 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'
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,12 +129,18 @@ 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/mindset_wordlist.yml
136
+ - data/misused_wordlist.yml
90
137
  - data/pronoun_association_wordlist.yml
91
138
  - lib/linter.rb
92
139
  - lib/linter/base_association.rb
140
+ - lib/linter/cli.rb
93
141
  - lib/linter/gender_association.rb
142
+ - lib/linter/mindset_association.rb
143
+ - lib/linter/misused_words.rb
94
144
  - lib/linter/pronoun_association.rb
95
145
  - lib/linter/version.rb
96
146
  - linter.gemspec