check_super_calls 0.1.0
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 +7 -0
- data/.gitignore +8 -0
- data/Gemfile +6 -0
- data/README.md +35 -0
- data/Rakefile +19 -0
- data/bin/check-super-calls +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/check_super_calls.gemspec +41 -0
- data/fixtures/ObjC/compliantFile.m +44 -0
- data/fixtures/ObjC/file.h +0 -0
- data/fixtures/ObjC/offendingFile.m +28 -0
- data/fixtures/swift/compliantFile.swift +32 -0
- data/fixtures/swift/nestedDirectory/anotherFile.swift +8 -0
- data/fixtures/swift/offendingFile.swift +23 -0
- data/lib/check_super_calls/arguments_parser.rb +49 -0
- data/lib/check_super_calls/helpers.rb +27 -0
- data/lib/check_super_calls/languages/obj_c.rb +89 -0
- data/lib/check_super_calls/languages/pattern.rb +17 -0
- data/lib/check_super_calls/languages/swift.rb +94 -0
- data/lib/check_super_calls/shell_adapter.rb +27 -0
- data/lib/check_super_calls/version.rb +3 -0
- data/lib/check_super_calls.rb +14 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: '06812c03236fefd007e9b11769f71d3cb9610bbd'
|
4
|
+
data.tar.gz: 41204f9a1ab42f061050053ff0829de65c7ebe3c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7f679d3aeac683b758cc7764117001057eb112f816105c575089a4cb623e0f4cb2a7586b7a4b27686dc3481fa1ae13e11514a4e2480c83022b5bc0079e06324a
|
7
|
+
data.tar.gz: e36d0fa75cb1c2e8add4485c95b8fd058e5e48f360f8e5fd167ef1589a96147540927332ce8f3fa7552652bfbe29891b0eb25de68b4e9025fd479c13368ce3ad
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# CheckSuperCalls
|
2
|
+
|
3
|
+
Script that checks if Swift and Objective C subclasses call specific superclass methods.
|
4
|
+
|
5
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/check_super_calls`. To experiment with that code, run `bin/console` for an interactive prompt.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'check_super_calls'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install check_super_calls
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Run check-super-calls path/to/project/directory.
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/check_super_calls.
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
3
|
+
|
4
|
+
desc 'Make tests output references'
|
5
|
+
task :make_test_references do
|
6
|
+
require_relative 'test/make_test_references'
|
7
|
+
make_test_references
|
8
|
+
puts
|
9
|
+
puts 'Finished generating test references, inspect them for correctness.'
|
10
|
+
puts
|
11
|
+
end
|
12
|
+
|
13
|
+
Rake::TestTask.new(:test) do |t|
|
14
|
+
t.libs << 'test'
|
15
|
+
t.libs << 'lib'
|
16
|
+
t.test_files = FileList['test/**/*_test.rb']
|
17
|
+
end
|
18
|
+
|
19
|
+
task default: :test
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'check_super_calls'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'check_super_calls/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'check_super_calls'
|
7
|
+
spec.version = CheckSuperCalls::VERSION
|
8
|
+
spec.authors = ['Andrei Nagy']
|
9
|
+
spec.email = ['nagy.andrei@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = 'Check calls to superclasses in iOS code.'
|
12
|
+
spec.description = 'Script that checks if Swift and Objective C subclasses call specific superclass methods.'
|
13
|
+
spec.homepage = 'https://github.com/andreinagy/check-super-calls'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
20
|
+
|
21
|
+
# spec.metadata['homepage_uri'] = spec.homepage
|
22
|
+
# spec.metadata["source_code_uri"] = "Put your gem's public repo URL here."
|
23
|
+
# spec.metadata["changelog_uri"] = "Put your gem's CHANGELOG.md URL here."
|
24
|
+
else
|
25
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
26
|
+
'public gem pushes.'
|
27
|
+
end
|
28
|
+
|
29
|
+
# Specify which files should be added to the gem when it is released.
|
30
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
31
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
32
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
33
|
+
end
|
34
|
+
spec.bindir = 'bin'
|
35
|
+
spec.executables = 'check-super-calls'
|
36
|
+
spec.require_paths = ['lib']
|
37
|
+
|
38
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
39
|
+
spec.add_development_dependency 'minitest', '~> 5.0'
|
40
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
41
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
- (void)viewDidLoad {
|
3
|
+
[super viewDidLoad];
|
4
|
+
}
|
5
|
+
|
6
|
+
- (void)viewWillAppear:(BOOL)animated {
|
7
|
+
[super viewWillAppear:animated];
|
8
|
+
}
|
9
|
+
|
10
|
+
- (void)viewWillDisappear:(BOOL)animated {
|
11
|
+
[super viewWillDisappear:animated];
|
12
|
+
}
|
13
|
+
|
14
|
+
- (void)viewDidAppear:(BOOL)animated {
|
15
|
+
[super viewDidAppear:animated];
|
16
|
+
}
|
17
|
+
|
18
|
+
- (void)viewDidDisappear:(BOOL)animated {
|
19
|
+
[super viewDidDisappear:animated];
|
20
|
+
}
|
21
|
+
|
22
|
+
- (void)viewWillLayoutSubviews {
|
23
|
+
[super viewWillLayoutSubviews];
|
24
|
+
}
|
25
|
+
|
26
|
+
- (void)viewDidLayoutSubviews {
|
27
|
+
[super viewDidLayoutSubviews];
|
28
|
+
}
|
29
|
+
|
30
|
+
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
31
|
+
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
32
|
+
if (self) {
|
33
|
+
|
34
|
+
}
|
35
|
+
return self;
|
36
|
+
}
|
37
|
+
|
38
|
+
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
39
|
+
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
40
|
+
if (self) {
|
41
|
+
|
42
|
+
}
|
43
|
+
return self;
|
44
|
+
}
|
File without changes
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
- (void)viewDidLoad {
|
3
|
+
}
|
4
|
+
|
5
|
+
- (void)viewWillAppear:(BOOL)animated {
|
6
|
+
}
|
7
|
+
|
8
|
+
- (void)viewWillDisappear:(BOOL)animated {
|
9
|
+
}
|
10
|
+
|
11
|
+
- (void)viewDidAppear:(BOOL)animated {
|
12
|
+
}
|
13
|
+
|
14
|
+
- (void)viewDidDisappear:(BOOL)animated {
|
15
|
+
}
|
16
|
+
|
17
|
+
- (void)viewWillLayoutSubviews {
|
18
|
+
}
|
19
|
+
|
20
|
+
- (void)viewDidLayoutSubviews {
|
21
|
+
}
|
22
|
+
|
23
|
+
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
24
|
+
if (self) {
|
25
|
+
|
26
|
+
}
|
27
|
+
return self;
|
28
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
override func viewDidLoad() {
|
3
|
+
super.viewDidLoad()
|
4
|
+
}
|
5
|
+
|
6
|
+
override func viewWillAppear(_ animated: Bool) {
|
7
|
+
super.viewWillAppear(animated)
|
8
|
+
}
|
9
|
+
|
10
|
+
override func viewWillDisappear(_ animated: Bool) {
|
11
|
+
super.viewWillDisappear(animated)
|
12
|
+
}
|
13
|
+
|
14
|
+
override func viewDidAppear(_ animated: Bool) {
|
15
|
+
super.viewDidAppear(animated)
|
16
|
+
}
|
17
|
+
|
18
|
+
override func viewDidDisappear(_ animated: Bool) {
|
19
|
+
super.viewDidDisappear(animated)
|
20
|
+
}
|
21
|
+
|
22
|
+
override func viewWillLayoutSubviews() {
|
23
|
+
super.viewWillLayoutSubviews()
|
24
|
+
}
|
25
|
+
|
26
|
+
override func viewDidLayoutSubviews() {
|
27
|
+
super.viewDidLayoutSubviews()
|
28
|
+
}
|
29
|
+
|
30
|
+
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
31
|
+
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
32
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
override func viewDidLoad() {
|
2
|
+
}
|
3
|
+
|
4
|
+
override func viewWillAppear(_ animated: Bool) {
|
5
|
+
}
|
6
|
+
|
7
|
+
override func viewWillDisappear(_ animated: Bool) {
|
8
|
+
}
|
9
|
+
|
10
|
+
override func viewDidAppear(_ animated: Bool) {
|
11
|
+
}
|
12
|
+
|
13
|
+
override func viewDidDisappear(_ animated: Bool) {
|
14
|
+
}
|
15
|
+
|
16
|
+
override func viewWillLayoutSubviews() {
|
17
|
+
}
|
18
|
+
|
19
|
+
override func viewDidLayoutSubviews() {
|
20
|
+
}
|
21
|
+
|
22
|
+
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
23
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
# https://docs.ruby-lang.org/en/2.1.0/OptionParser.html
|
4
|
+
Options = Struct.new(:input_directory)
|
5
|
+
|
6
|
+
# Parses command line arguments
|
7
|
+
class Parser
|
8
|
+
def self.default_options
|
9
|
+
result = Options.new
|
10
|
+
result.input_directory = '.'
|
11
|
+
result
|
12
|
+
end
|
13
|
+
private_class_method :default_options
|
14
|
+
|
15
|
+
def self.parse(argv)
|
16
|
+
# If no arguments supplied, print help
|
17
|
+
argv << '-h' if argv.empty?
|
18
|
+
|
19
|
+
result = default_options
|
20
|
+
|
21
|
+
options_parser = OptionParser.new do |o|
|
22
|
+
o.banner = 'Usage: check-super-calls.rb [input directory]'
|
23
|
+
|
24
|
+
o.on('-h',
|
25
|
+
'--help',
|
26
|
+
'Prints this help') do
|
27
|
+
puts options_parser
|
28
|
+
exit 0
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
begin
|
33
|
+
options_parser.parse!(argv)
|
34
|
+
rescue StandardError => exception
|
35
|
+
puts exception
|
36
|
+
puts options_parser
|
37
|
+
exit 1
|
38
|
+
end
|
39
|
+
|
40
|
+
result.input_directory = argv.pop
|
41
|
+
if result.input_directory.nil? || !Dir.exist?(result.input_directory)
|
42
|
+
puts 'Can\'t find directory ' + result.input_directory
|
43
|
+
Parser.parse %w[--help]
|
44
|
+
exit 0
|
45
|
+
end
|
46
|
+
|
47
|
+
result
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'find'
|
2
|
+
|
3
|
+
# Convenience utilities.
|
4
|
+
|
5
|
+
def find_files(ignore_list, base_path, extension)
|
6
|
+
file_paths = []
|
7
|
+
Find.find(base_path) do |path|
|
8
|
+
next if File.directory? path
|
9
|
+
next if path !~ extension
|
10
|
+
|
11
|
+
ignore_matches = (ignore_list || []).select do |item|
|
12
|
+
path.include? item
|
13
|
+
end
|
14
|
+
should_ignore = ignore_matches.any?
|
15
|
+
|
16
|
+
file_paths << path unless should_ignore
|
17
|
+
end
|
18
|
+
file_paths
|
19
|
+
end
|
20
|
+
|
21
|
+
def check_line_overrides(_string)
|
22
|
+
false
|
23
|
+
end
|
24
|
+
|
25
|
+
def check_line_calls_super(_string)
|
26
|
+
false
|
27
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require_relative 'pattern.rb'
|
2
|
+
|
3
|
+
class ObjC
|
4
|
+
attr_accessor :file_regex, :patterns
|
5
|
+
def initialize
|
6
|
+
@file_regex = regex_ending_with('(h|m)')
|
7
|
+
@patterns = [
|
8
|
+
Pattern.new(
|
9
|
+
'[super viewDidLoad]',
|
10
|
+
regex_any_spaces_between(
|
11
|
+
['-', '\(', 'void', '\)', 'viewDidLoad', '\{']
|
12
|
+
),
|
13
|
+
regex_any_spaces_between(
|
14
|
+
['\[', 'super', 'viewDidLoad', '\]']
|
15
|
+
)
|
16
|
+
),
|
17
|
+
Pattern.new(
|
18
|
+
'[super viewWillAppear:animated]',
|
19
|
+
regex_any_spaces_between(
|
20
|
+
['-', '\(', 'void', '\)',
|
21
|
+
'viewWillAppear:', '\(', 'BOOL', '\)', 'animated', '\{']
|
22
|
+
),
|
23
|
+
regex_any_spaces_between(
|
24
|
+
['\[', 'super', 'viewWillAppear:animated', '\]']
|
25
|
+
)
|
26
|
+
),
|
27
|
+
Pattern.new(
|
28
|
+
'[super viewWillDisappear:animated]',
|
29
|
+
regex_any_spaces_between(
|
30
|
+
['-', '\(', 'void', '\)',
|
31
|
+
'viewWillDisappear:', '\(', 'BOOL', '\)', 'animated', '\{']
|
32
|
+
),
|
33
|
+
regex_any_spaces_between(
|
34
|
+
['\[', 'super', 'viewWillDisappear:animated', '\]']
|
35
|
+
)
|
36
|
+
),
|
37
|
+
Pattern.new(
|
38
|
+
'[super viewDidAppear:animated]',
|
39
|
+
regex_any_spaces_between(
|
40
|
+
['-', '\(', 'void', '\)',
|
41
|
+
'viewDidAppear:', '\(', 'BOOL', '\)', 'animated', '\{']
|
42
|
+
),
|
43
|
+
regex_any_spaces_between(
|
44
|
+
['\[', 'super', 'viewDidAppear:animated', '\]']
|
45
|
+
)
|
46
|
+
),
|
47
|
+
Pattern.new(
|
48
|
+
'[super viewDidDisappear:animated]',
|
49
|
+
regex_any_spaces_between(
|
50
|
+
['-', '\(', 'void', '\)',
|
51
|
+
'viewDidDisappear:', '\(', 'BOOL', '\)', 'animated', '\{']
|
52
|
+
),
|
53
|
+
regex_any_spaces_between(
|
54
|
+
['\[', 'super', 'viewDidDisappear:animated', '\]']
|
55
|
+
)
|
56
|
+
),
|
57
|
+
Pattern.new(
|
58
|
+
'[super viewWillLayoutSubviews]',
|
59
|
+
regex_any_spaces_between(
|
60
|
+
['-', '\(', 'void', '\)', 'viewWillLayoutSubviews', '\{']
|
61
|
+
),
|
62
|
+
regex_any_spaces_between(
|
63
|
+
['\[', 'super', 'viewWillLayoutSubviews', '\]']
|
64
|
+
)
|
65
|
+
),
|
66
|
+
Pattern.new(
|
67
|
+
'[super viewDidLayoutSubviews]',
|
68
|
+
regex_any_spaces_between(
|
69
|
+
['-', '\(', 'void', '\)', 'viewDidLayoutSubviews', '\{']
|
70
|
+
),
|
71
|
+
regex_any_spaces_between(
|
72
|
+
['\[', 'super', 'viewDidLayoutSubviews', '\]']
|
73
|
+
)
|
74
|
+
),
|
75
|
+
Pattern.new(
|
76
|
+
'[super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];',
|
77
|
+
regex_any_spaces_between(
|
78
|
+
['-', '\(', '(id|instancetype)', '\)',
|
79
|
+
'initWithNibName:', '\(', 'NSString', '\*', '\)', 'nibNameOrNil',
|
80
|
+
'bundle:', '\(', 'NSBundle', '\*', '\)', 'nibBundleOrNil', '\{']
|
81
|
+
),
|
82
|
+
regex_any_spaces_between(
|
83
|
+
['\[', 'super', 'initWithNibName:', 'nibNameOrNil',
|
84
|
+
'bundle:', 'nibBundleOrNil' '\]']
|
85
|
+
)
|
86
|
+
)
|
87
|
+
]
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
class Pattern
|
3
|
+
attr_accessor :name, :definition, :check
|
4
|
+
def initialize(name, definition, check)
|
5
|
+
@name = name
|
6
|
+
@definition = definition
|
7
|
+
@check = check
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def regex_ending_with(string)
|
12
|
+
Regexp.new('\\.' + string + '$')
|
13
|
+
end
|
14
|
+
|
15
|
+
def regex_any_spaces_between(array)
|
16
|
+
Regexp.new(array.join('\\s*'))
|
17
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require_relative 'pattern.rb'
|
2
|
+
|
3
|
+
class Swift
|
4
|
+
attr_accessor :file_regex, :patterns
|
5
|
+
def initialize
|
6
|
+
@file_regex = regex_ending_with('swift')
|
7
|
+
@patterns = [
|
8
|
+
Pattern.new(
|
9
|
+
'super.viewDidLoad()',
|
10
|
+
regex_any_spaces_between(
|
11
|
+
['override', 'func', 'viewDidLoad', '\(', '\)', '\{']
|
12
|
+
),
|
13
|
+
regex_any_spaces_between(
|
14
|
+
['override', 'func', 'viewDidLoad', '\(', '\)',
|
15
|
+
'\{(.|s)*', 'super', '\.viewDidLoad', '\(', '\)']
|
16
|
+
)
|
17
|
+
),
|
18
|
+
Pattern.new(
|
19
|
+
'super.viewWillAppear(animated)',
|
20
|
+
regex_any_spaces_between(
|
21
|
+
['override', 'func', 'viewWillAppear\(_ animated: Bool\) \{']
|
22
|
+
),
|
23
|
+
regex_any_spaces_between(
|
24
|
+
['override', 'func', 'viewWillAppear\(_ animated: Bool\) \{',
|
25
|
+
'super', '.viewWillAppear\(animated\)']
|
26
|
+
)
|
27
|
+
),
|
28
|
+
Pattern.new(
|
29
|
+
'super.viewWillDisappear(animated)',
|
30
|
+
regex_any_spaces_between(
|
31
|
+
['override', 'func', 'viewWillDisappear\(_ animated: Bool\) \{']
|
32
|
+
),
|
33
|
+
regex_any_spaces_between(
|
34
|
+
['override', 'func', 'viewWillDisappear\(_ animated: Bool\) \{',
|
35
|
+
'super', '.viewWillDisappear\(animated\)']
|
36
|
+
)
|
37
|
+
),
|
38
|
+
Pattern.new(
|
39
|
+
'super.viewDidAppear(animated)',
|
40
|
+
regex_any_spaces_between(
|
41
|
+
['override', 'func', 'viewDidAppear\(_ animated: Bool\) \{']
|
42
|
+
),
|
43
|
+
regex_any_spaces_between(
|
44
|
+
['override', 'func', 'viewDidAppear\(_ animated: Bool\) \{',
|
45
|
+
'super', '.viewDidAppear\(animated\)']
|
46
|
+
)
|
47
|
+
),
|
48
|
+
Pattern.new(
|
49
|
+
'super.viewDidDisappear(animated)',
|
50
|
+
regex_any_spaces_between(
|
51
|
+
['override', 'func', 'viewDidDisappear\(_ animated: Bool\) \{']
|
52
|
+
),
|
53
|
+
regex_any_spaces_between(
|
54
|
+
['override', 'func', 'viewDidDisappear\(_ animated: Bool\) \{',
|
55
|
+
'super', '.viewDidDisappear\(animated\)']
|
56
|
+
)
|
57
|
+
),
|
58
|
+
|
59
|
+
Pattern.new(
|
60
|
+
'super.viewWillLayoutSubviews()',
|
61
|
+
regex_any_spaces_between(
|
62
|
+
['override', 'func', 'viewWillLayoutSubviews\(\) \{']
|
63
|
+
),
|
64
|
+
regex_any_spaces_between(
|
65
|
+
['override', 'func', 'viewWillLayoutSubviews\(\) \{',
|
66
|
+
'super', '.viewWillLayoutSubviews\(\)']
|
67
|
+
)
|
68
|
+
),
|
69
|
+
Pattern.new(
|
70
|
+
'super.viewDidLayoutSubviews()',
|
71
|
+
regex_any_spaces_between(
|
72
|
+
['override', 'func', 'viewDidLayoutSubviews\(\) \{']
|
73
|
+
),
|
74
|
+
regex_any_spaces_between(
|
75
|
+
['override', 'func', 'viewDidLayoutSubviews\(\) \{',
|
76
|
+
'super', '.viewDidLayoutSubviews\(\)']
|
77
|
+
)
|
78
|
+
),
|
79
|
+
|
80
|
+
Pattern.new(
|
81
|
+
'super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)',
|
82
|
+
regex_any_spaces_between(
|
83
|
+
['override', 'init\(nibName nibNameOrNil: String\?,' \
|
84
|
+
' bundle nibBundleOrNil: Bundle\?\) \{']
|
85
|
+
),
|
86
|
+
regex_any_spaces_between(
|
87
|
+
['override', 'init', '\(nibName nibNameOrNil: String\?,' \
|
88
|
+
' bundle nibBundleOrNil: Bundle\?\) \{',
|
89
|
+
'super', '.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)']
|
90
|
+
)
|
91
|
+
)
|
92
|
+
]
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative 'helpers'
|
2
|
+
require_relative 'languages/swift.rb'
|
3
|
+
require_relative 'languages/obj_c.rb'
|
4
|
+
|
5
|
+
# Adapter which handles shell access.
|
6
|
+
class ShellAdapter
|
7
|
+
def process_files(ignore_list, base_path)
|
8
|
+
[
|
9
|
+
Swift.new,
|
10
|
+
ObjC.new
|
11
|
+
].each do |language|
|
12
|
+
result = find_files(ignore_list, base_path, language.file_regex)
|
13
|
+
|
14
|
+
result.each do |file|
|
15
|
+
file_content = File.open(file, 'r:UTF-8').read
|
16
|
+
|
17
|
+
language.patterns.each do |pattern|
|
18
|
+
next if file_content !~ pattern.definition
|
19
|
+
|
20
|
+
if file_content !~ pattern.check
|
21
|
+
puts file + ': ' + pattern.name + ' not called'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'check_super_calls/version'
|
2
|
+
require 'check_super_calls/arguments_parser.rb'
|
3
|
+
require 'check_super_calls/shell_adapter.rb'
|
4
|
+
|
5
|
+
module CheckSuperCalls
|
6
|
+
class Error < StandardError; end
|
7
|
+
# Your code goes here...
|
8
|
+
def self.main(_args)
|
9
|
+
options = Parser.parse(ARGV)
|
10
|
+
|
11
|
+
shell = ShellAdapter.new
|
12
|
+
result = shell.process_files(nil, options.input_directory)
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: check_super_calls
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrei Nagy
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-02-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: Script that checks if Swift and Objective C subclasses call specific
|
56
|
+
superclass methods.
|
57
|
+
email:
|
58
|
+
- nagy.andrei@gmail.com
|
59
|
+
executables:
|
60
|
+
- check-super-calls
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- Gemfile
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/check-super-calls
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- check_super_calls.gemspec
|
72
|
+
- fixtures/ObjC/compliantFile.m
|
73
|
+
- fixtures/ObjC/file.h
|
74
|
+
- fixtures/ObjC/offendingFile.m
|
75
|
+
- fixtures/swift/compliantFile.swift
|
76
|
+
- fixtures/swift/nestedDirectory/anotherFile.swift
|
77
|
+
- fixtures/swift/offendingFile.swift
|
78
|
+
- lib/check_super_calls.rb
|
79
|
+
- lib/check_super_calls/arguments_parser.rb
|
80
|
+
- lib/check_super_calls/helpers.rb
|
81
|
+
- lib/check_super_calls/languages/obj_c.rb
|
82
|
+
- lib/check_super_calls/languages/pattern.rb
|
83
|
+
- lib/check_super_calls/languages/swift.rb
|
84
|
+
- lib/check_super_calls/shell_adapter.rb
|
85
|
+
- lib/check_super_calls/version.rb
|
86
|
+
homepage: https://github.com/andreinagy/check-super-calls
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata:
|
90
|
+
allowed_push_host: https://rubygems.org
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.5.2.3
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: Check calls to superclasses in iOS code.
|
111
|
+
test_files: []
|