rubocop-discourse 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 01276e2b010e4c0639beb5619f280ff8f74e68046ca859c80647c5b0bf507b25
4
+ data.tar.gz: 8827a7949b2e1503548f03bb71a15ddbbb21327028fdd47b2d24e05efea7a66e
5
+ SHA512:
6
+ metadata.gz: 45f4b69112056ffa8f94f95bb6beb27ec1f66edffb0aef45bbbd310cb0e07e2c9c6c23c6b8d60944cda8088a103cd7d0eb65c53327e97ae35a1979a897c793a8
7
+ data.tar.gz: bb5cd21c59f9e2403158267ff628a89493e07ac9fb372966f561f91edc50c4f3eb5d84f9020d17a49e29d4314aa25417e2d3d25554f732df349b21256d15f183
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module DiscourseCops
6
+ # Avoid using chdir - it is not thread safe.
7
+ #
8
+ # Instead, you may be able to use:
9
+ # Discourse::Utils.execute_command(chdir: 'test') do |runner|
10
+ # runner.exec('pwd')
11
+ # end
12
+ #
13
+ # @example
14
+ # # bad
15
+ # Dir.chdir('test')
16
+ class NoChdir < Cop
17
+ MSG = 'Chdir is not thread safe.'
18
+
19
+ def_node_matcher :using_dir_chdir?, <<-MATCHER
20
+ (send (const nil? :Dir) :chdir ...)
21
+ MATCHER
22
+
23
+ def_node_matcher :using_fileutils_cd?, <<-MATCHER
24
+ (send (const nil? :FileUtils) :cd ...)
25
+ MATCHER
26
+
27
+ def on_send(node)
28
+ return if !(using_dir_chdir?(node) || using_fileutils_cd?(node))
29
+ add_offense(node, message: MSG)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubocop-discourse
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - David Taylor
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-11-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rubocop
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.69.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.69.0
27
+ description:
28
+ email:
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/rubocop/cop/discourse_cops.rb
34
+ homepage:
35
+ licenses:
36
+ - MIT
37
+ metadata: {}
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubygems_version: 3.0.3
54
+ signing_key:
55
+ specification_version: 4
56
+ summary: Custom rubocop cops used by Discourse
57
+ test_files: []