fui 0.4.1 → 0.6.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 +5 -5
- data/CHANGELOG.md +24 -8
- data/LICENSE.md +1 -1
- data/README.md +67 -15
- data/RELEASING.md +61 -0
- data/bin/fui +28 -16
- data/lib/fui/finder.rb +55 -17
- data/lib/fui/header.rb +1 -0
- data/lib/fui/project.rb +32 -0
- data/lib/fui/version.rb +1 -1
- data/lib/fui.rb +1 -0
- metadata +13 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: e1b8934ca5afcaf97a11129a196887f07aa1596113b40c18e061db018410df26
|
|
4
|
+
data.tar.gz: d8639e7b395f89c874c81cbe0d5613dea5e5db59a7e0ceb389e0ea32a361a0be
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8bc77ab09250e68b6ff3f54111f107852d1a988cabfb875c167662363c3040cc904d37ac9133275741190aa11f72477e3bf19d5b6074d9ceffc6bfadc22ff5a1
|
|
7
|
+
data.tar.gz: 4397a5d1a4c8b19d7b4dc91b50808200c30d96083e311a3f7bf816df3b1b58922827e98bcfb77955fb02a4d977a8763bf03d5d59bf3c4ac45ff51f499b7ad72a
|
data/CHANGELOG.md
CHANGED
|
@@ -1,29 +1,45 @@
|
|
|
1
|
-
### 0.
|
|
1
|
+
### 0.6.0 (2026/04/12)
|
|
2
2
|
|
|
3
|
-
*
|
|
3
|
+
* [#45](https://github.com/dblock/fui/pull/45): Migrated from Travis CI to GitHub Actions with danger-pr-comment workflow - [@dblock](https://github.com/dblock).
|
|
4
|
+
* [#47](https://github.com/dblock/fui/pull/47): Fixed `ArgumentError: invalid byte sequence in UTF-8` when processing files with non-UTF-8 encoding - [@dblock](https://github.com/dblock).
|
|
5
|
+
* [#48](https://github.com/dblock/fui/pull/48): Fixed `NameError: undefined local variable or method 'project_path'` in verbose mode - [@dblock](https://github.com/dblock).
|
|
6
|
+
* [#49](https://github.com/dblock/fui/pull/49): Added summary output to `find` command: prints `Found N unused header(s).` or `No unused imports found.` - [@dblock](https://github.com/dblock).
|
|
7
|
+
* [#50](https://github.com/dblock/fui/pull/50): Fixed `delete` command to also remove `.mm` (Objective-C++) implementation files - [@dblock](https://github.com/dblock).
|
|
8
|
+
* [#51](https://github.com/dblock/fui/pull/51): Added support for Ruby 4.x - [@dblock](https://github.com/dblock).
|
|
9
|
+
* [#52](https://github.com/dblock/fui/pull/52): Clarified README: fui finds unreferenced header files, not unused imports within files - [@dblock](https://github.com/dblock).
|
|
4
10
|
|
|
5
|
-
### 0.
|
|
11
|
+
### 0.5.0 (2018/12/19)
|
|
12
|
+
|
|
13
|
+
* [#29](https://github.com/dblock/fui/pull/29): Added support for ignoring paths through `-i`, `--ignore-path` - [@jeffctown](https://github.com/jeffctown).
|
|
14
|
+
* [#28](https://github.com/dblock/fui/pull/28): Added support for finding global imports (bracket notation) - [@jeffctown](https://github.com/jeffctown).
|
|
15
|
+
* [#28](https://github.com/dblock/fui/pull/28): Added ability to turn off global or local import checks through `-g`, `--ignore-global-imports` or `-l`, `--ignore-local-imports` - [@jeffctown](https://github.com/jeffctown).
|
|
16
|
+
* [#28](https://github.com/dblock/fui/pull/28): The `--ignorexib` option has been renamed to `--ignore-xib-files` - [@jeffctown](https://github.com/jeffctown).
|
|
17
|
+
* [#31](https://github.com/dblock/fui/pull/31): Added Danger, PR linter and a README TOC - [@jeffctown](https://github.com/jeffctown).
|
|
18
|
+
* [#32](https://github.com/dblock/fui/pull/32): Added support for ignoring bridging headers - [@jeffctown](https://github.com/jeffctown).
|
|
19
|
+
* [#33](https://github.com/dblock/fui/pull/33): Added RELEASING.md to document release process - [@jeffctown](https://github.com/jeffctown).
|
|
20
|
+
|
|
21
|
+
### 0.4.1 (2017/8/16)
|
|
6
22
|
|
|
7
23
|
* [#24](https://github.com/dblock/fui/pull/24): Support .mm files - [@shachlan](https://github.com/Shachlan).
|
|
8
24
|
|
|
9
|
-
### 0.4.0 (5/14
|
|
25
|
+
### 0.4.0 (2016/5/14)
|
|
10
26
|
|
|
11
27
|
* [#20](https://github.com/dblock/fui/pull/20): Added `-x`, `--ignorexib`, find unused classes referenced from its own XIB - [@Ezor](https://github.com/Ezor).
|
|
12
28
|
|
|
13
|
-
### 0.3.0 (2/7
|
|
29
|
+
### 0.3.0 (2014/2/7)
|
|
14
30
|
|
|
15
31
|
* [#5](https://github.com/dblock/fui/issues/5): Explicitly require Ruby 1.9.3 or later in .gemspec - [@paulyoung](https://github.com/paulyoung).
|
|
16
32
|
* [#4](https://github.com/dblock/fui/issues/4): Added support for .storyboard and .xib `customClass` references - [@dblock](https://github.com/dblock).
|
|
17
33
|
|
|
18
|
-
### 0.2.0 (1/23
|
|
34
|
+
### 0.2.0 (2014/1/23)
|
|
19
35
|
|
|
20
36
|
* By default will display "(simulation)" because no actual files are being deleted - [@dblock](https://github.com/dblock).
|
|
21
37
|
* Fui's exit code with `find` will be the number of unused references found - [@dblock](https://github.com/dblock).
|
|
22
38
|
|
|
23
|
-
### 0.1.1 (1/22
|
|
39
|
+
### 0.1.1 (2014/1/22)
|
|
24
40
|
|
|
25
41
|
* Fix: properly handle .pch includes - [@dblock](https://github.com/dblock).
|
|
26
42
|
|
|
27
|
-
### 0.1.0 (1/22
|
|
43
|
+
### 0.1.0 (2014/1/22)
|
|
28
44
|
|
|
29
45
|
* Initial public release, based on code by [@dstnbrkr](https://github.com/dstnbrkr) - [@dblock](https://github.com/dblock).
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
|
@@ -2,51 +2,103 @@ Fui
|
|
|
2
2
|
==========
|
|
3
3
|
|
|
4
4
|
[](https://badge.fury.io/rb/fui)
|
|
5
|
-
[](https://github.com/dblock/fui/actions/workflows/test.yml)
|
|
6
6
|
|
|
7
7
|
Find unused Objective-C imports.
|
|
8
8
|
|
|
9
|
+
> **What fui does:** finds header (`.h`) files that are never imported anywhere in your project — i.e. classes that can potentially be deleted entirely.
|
|
10
|
+
>
|
|
11
|
+
> **What fui does not do:** find `#import` statements within a file that are unused by that file's code. For that, use a tool like [Clang's unused-includes warning](https://clang.llvm.org/docs/DiagnosticsReference.html) or AppCode.
|
|
12
|
+
|
|
13
|
+
# Table of Contents
|
|
14
|
+
|
|
15
|
+
- [Usage](#usage)
|
|
16
|
+
- [Get Help](#get-help)
|
|
17
|
+
- [Find Unused Classes in the Current Directory](#find-unused-classes-in-the-current-directory)
|
|
18
|
+
- [Find Unused Classes in any Path](#find-unused-classes-in-any-path)
|
|
19
|
+
- [Skip Interface Builder (.xib) Files](#skip-interface-builder-xib-files)
|
|
20
|
+
- [Ignore Local Imports](#ignore-local-imports)
|
|
21
|
+
- [Ignore Global Imports](#ignore-global-imports)
|
|
22
|
+
- [Ignore a Path](#ignore-a-path)
|
|
23
|
+
- [Ignore Multiple Paths](#ignore-multiple-paths)
|
|
24
|
+
- [Delete All Unused Class Files with Prompt](#delete-all-unused-class-files-with-prompt)
|
|
25
|
+
- [Xcode Plugin](#xcode-plugin)
|
|
26
|
+
- [Contributing](#contributing)
|
|
27
|
+
- [Copyright and License](#copyright-and-license)
|
|
28
|
+
|
|
9
29
|
## Usage
|
|
10
30
|
|
|
11
|
-
```
|
|
31
|
+
```sh
|
|
12
32
|
gem install fui
|
|
13
33
|
```
|
|
14
34
|
|
|
15
|
-
|
|
35
|
+
### Get Help
|
|
16
36
|
|
|
17
|
-
```
|
|
37
|
+
```sh
|
|
18
38
|
fui help
|
|
19
39
|
```
|
|
20
40
|
|
|
21
|
-
|
|
41
|
+
### Find Unused Classes in the Current Directory
|
|
22
42
|
|
|
23
|
-
```
|
|
43
|
+
```sh
|
|
24
44
|
fui find
|
|
25
45
|
```
|
|
26
46
|
|
|
27
|
-
The `find` command lists all
|
|
47
|
+
The `find` command lists all header (`.h`) files that are not imported anywhere in the project, and exits with the number of such files found.
|
|
28
48
|
|
|
29
|
-
|
|
49
|
+
### Find Unused Classes in any Path
|
|
30
50
|
|
|
31
|
-
```
|
|
51
|
+
```sh
|
|
32
52
|
fui --path=~/source/project/Name find
|
|
33
53
|
```
|
|
34
54
|
|
|
35
|
-
|
|
55
|
+
### Skip Interface Builder (.xib) Files
|
|
36
56
|
|
|
37
|
-
|
|
57
|
+
Running `fui` with `-x` (or `--ignore-xib-files`) will, for example, mark `Foo.h` as unused when `Foo.xib` holds a reference to the `Foo` class and no other references to Foo.h exist.
|
|
38
58
|
|
|
39
|
-
```
|
|
59
|
+
```sh
|
|
40
60
|
fui -x --path=~/source/project/Name find
|
|
41
61
|
```
|
|
42
62
|
|
|
43
|
-
|
|
63
|
+
### Ignore Local Imports
|
|
64
|
+
|
|
65
|
+
Running `fui` with `-l` (or `--ignore-local-imports`) will, for example, mark `Foo.h` as unused when `Bar.h` contains a local (quotation syntax) import of `Foo.h` (eg. `#import Foo.h`).
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
fui -l --path=~/source/project/Name find
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Ignore Global Imports
|
|
72
|
+
|
|
73
|
+
Running `fui` with `-g` (or `--ignore-global-imports`) will, for example, mark `Foo.h` as unused when `Bar.h` contains a global (bracket syntax) import of `Foo.h` (eg. `#import <Framework/Foo.h>`).
|
|
44
74
|
|
|
75
|
+
```sh
|
|
76
|
+
fui -g --path=~/source/project/Name find
|
|
45
77
|
```
|
|
78
|
+
|
|
79
|
+
### Ignore a Path
|
|
80
|
+
|
|
81
|
+
Running `fui` with `-i` (or `--ignore-path`) will, for example, ignore a `Pods` folder when searching for headers or referencing files.
|
|
82
|
+
|
|
83
|
+
```sh
|
|
84
|
+
fui --path=~/source/project/Name --ignore-path=Pods find
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Ignore Multiple Paths
|
|
88
|
+
|
|
89
|
+
Running `fui` with `-i` (or `--ignore-path`) can ignore multiple folders when searching for headers or referencing files.
|
|
90
|
+
|
|
91
|
+
```sh
|
|
92
|
+
fui --path=~/source/project/Name --ignore-path=Pods --ignore-path=Libraries find
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Delete All Unused Class Files with Prompt
|
|
96
|
+
|
|
97
|
+
```sh
|
|
46
98
|
fui --path=~/source/project/Name delete --perform --prompt
|
|
47
99
|
```
|
|
48
100
|
|
|
49
|
-
|
|
101
|
+
## Xcode Plugin
|
|
50
102
|
|
|
51
103
|
Use [xcfui](https://github.com/jcavar/xcfui) for integration with Xcode.
|
|
52
104
|
|
|
@@ -56,6 +108,6 @@ There're [a few feature requests and known issues](https://github.com/dblock/fui
|
|
|
56
108
|
|
|
57
109
|
## Copyright and License
|
|
58
110
|
|
|
59
|
-
Copyright (c) 2014, Daniel Doubrovkine, [Artsy](http://artsy.github.io), based on code by [Dustin Barker](https://github.com/dstnbrkr).
|
|
111
|
+
Copyright (c) 2014-2018, Daniel Doubrovkine, [Artsy](http://artsy.github.io), based on code by [Dustin Barker](https://github.com/dstnbrkr).
|
|
60
112
|
|
|
61
113
|
This project is licensed under the [MIT License](LICENSE.md).
|
data/RELEASING.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Releasing fui
|
|
2
|
+
|
|
3
|
+
There are no hard rules about when to release fui. Release bug fixes frequently, features not so frequently, and breaking changes rarely.
|
|
4
|
+
|
|
5
|
+
### Release
|
|
6
|
+
|
|
7
|
+
Run tests, check that all tests succeed locally.
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
bundle install
|
|
11
|
+
rake
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Check that the last build succeeded in [GitHub Actions](https://github.com/dblock/fui/actions).
|
|
15
|
+
|
|
16
|
+
Change "Next" in [CHANGELOG.md](CHANGELOG.md) to the current date.
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
### 0.4.0 (2016/5/14)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Remove the line with "Your contribution here.", since there will be no more contributions to this release.
|
|
23
|
+
|
|
24
|
+
Commit your changes.
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
git add CHANGELOG.md
|
|
28
|
+
git commit -m "Preparing for release, 0.4.0."
|
|
29
|
+
git push origin master
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Release.
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
$ rake release
|
|
36
|
+
|
|
37
|
+
fui 0.4.0 built to pkg/fui-0.4.0.gem.
|
|
38
|
+
Tagged v0.4.0.
|
|
39
|
+
Pushed git commits and tags.
|
|
40
|
+
Pushed fui 0.4.0 to rubygems.org.
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Prepare for the Next Version
|
|
44
|
+
|
|
45
|
+
Add the next release to [CHANGELOG.md](CHANGELOG.md).
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
### 0.4.1 (Next)
|
|
49
|
+
|
|
50
|
+
* Your contribution here.
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Increment the third version number in [lib/fui/version.rb](lib/fui/version.rb).
|
|
54
|
+
|
|
55
|
+
Commit your changes.
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
git add CHANGELOG.md lib/fui/version.rb
|
|
59
|
+
git commit -m "Preparing for next development iteration, 0.4.1."
|
|
60
|
+
git push origin master
|
|
61
|
+
```
|
data/bin/fui
CHANGED
|
@@ -6,13 +6,16 @@ include GLI::App
|
|
|
6
6
|
|
|
7
7
|
program_desc 'Find unused imports in an Objective-C codebase.'
|
|
8
8
|
|
|
9
|
-
flag [
|
|
10
|
-
|
|
11
|
-
switch [
|
|
9
|
+
flag %i[p path], desc: 'Path to search.', default_value: Dir.pwd
|
|
10
|
+
flag %i[i ignore-path], desc: 'Path to ignore.', default_value: nil, multiple: true
|
|
11
|
+
switch %i[v verbose], desc: 'Produce verbose output.', default_value: false
|
|
12
|
+
switch %i[x ignore-xib-files], desc: 'Ignore interface builder (.xib) files.', default_value: false
|
|
13
|
+
switch %i[g ignore-global-imports], desc: 'Ignores imports using a global (angle bracket) format.', default_value: false
|
|
14
|
+
switch %i[l ignore-local-imports], desc: 'Ignores imports using a local (quote) format.', default_value: false
|
|
12
15
|
|
|
13
16
|
default_command :find
|
|
14
17
|
|
|
15
|
-
pre do |global_options, _command,
|
|
18
|
+
pre do |global_options, _command, _options, _args|
|
|
16
19
|
options = global_options.dup
|
|
17
20
|
path = options.delete(:path)
|
|
18
21
|
$fui = Fui::Finder.new(path, options)
|
|
@@ -34,14 +37,20 @@ command :find do |c|
|
|
|
34
37
|
puts relative_path
|
|
35
38
|
end
|
|
36
39
|
end
|
|
37
|
-
|
|
40
|
+
count = $fui.unused_references.count
|
|
41
|
+
if count > 0
|
|
42
|
+
puts "Found #{count} unused #{count == 1 ? 'header' : 'headers'}."
|
|
43
|
+
else
|
|
44
|
+
puts 'No unused imports found.'
|
|
45
|
+
end
|
|
46
|
+
exit_now! nil, count
|
|
38
47
|
end
|
|
39
48
|
end
|
|
40
49
|
|
|
41
50
|
desc 'Delete header and implementation files of unused classes'
|
|
42
51
|
command :delete do |c|
|
|
43
|
-
c.switch [
|
|
44
|
-
c.switch [
|
|
52
|
+
c.switch %i[t prompt], desc: 'Prompt on delete', default_value: true
|
|
53
|
+
c.switch %i[f perform], desc: 'Actually perform deletion', default_value: false, negatable: false
|
|
45
54
|
|
|
46
55
|
c.action do |global_options, options, _args|
|
|
47
56
|
begin
|
|
@@ -54,7 +63,7 @@ command :delete do |c|
|
|
|
54
63
|
end.each do |k, _v|
|
|
55
64
|
relative_path = Pathname.new(k.path).relative_path_from(root).to_s
|
|
56
65
|
if options[:prompt]
|
|
57
|
-
print "Remove #{relative_path}(.m) [y/N] "
|
|
66
|
+
print "Remove #{relative_path}(.m/.mm) [y/N] "
|
|
58
67
|
response = STDIN.getc.upcase
|
|
59
68
|
puts "#{response.chr}\r\n"
|
|
60
69
|
next unless response.chr == 'Y'
|
|
@@ -65,15 +74,18 @@ command :delete do |c|
|
|
|
65
74
|
puts "#{relative_path}#{options[:perform] ? '' : ' (simulation)'}\r\n"
|
|
66
75
|
end
|
|
67
76
|
File.delete(k.path) if options[:perform]
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
77
|
+
['.m', '.mm'].each do |ext|
|
|
78
|
+
impl_path = k.path.gsub(/\.h$/, ext)
|
|
79
|
+
next unless File.exist?(impl_path)
|
|
80
|
+
|
|
81
|
+
relative_path = Pathname.new(impl_path).relative_path_from(root).to_s
|
|
82
|
+
if global_options[:verbose]
|
|
83
|
+
puts "Removing #{relative_path}#{options[:perform] ? '' : ' (simulation)'}\r\n"
|
|
84
|
+
else
|
|
85
|
+
puts "#{relative_path}#{options[:perform] ? '' : ' (simulation)'}\r\n"
|
|
86
|
+
end
|
|
87
|
+
File.delete(impl_path) if options[:perform]
|
|
75
88
|
end
|
|
76
|
-
File.delete(impl_path) if options[:perform]
|
|
77
89
|
end
|
|
78
90
|
ensure
|
|
79
91
|
system('stty -raw echo')
|
data/lib/fui/finder.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
module Fui
|
|
2
|
+
# A class to find various things in an Objective C project.
|
|
2
3
|
class Finder
|
|
3
4
|
attr_reader :path, :options
|
|
4
5
|
|
|
@@ -9,7 +10,21 @@ module Fui
|
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
def headers
|
|
12
|
-
@headers ||=
|
|
13
|
+
@headers ||= find(path) { |path| Header.header?(path) }.collect { |path| Header.new(path) }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def bridging_headers
|
|
17
|
+
@bridging_headers ||= find(path) { |path| Project.project?(path) }.collect { |path| Project.new(path).bridging_headers(options[:verbose]) }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def ignores
|
|
21
|
+
return unless options['ignore-path']
|
|
22
|
+
|
|
23
|
+
@ignores ||= options['ignore-path'].map do |i|
|
|
24
|
+
raise Errno::ENOENT, i unless Dir.exist?(i)
|
|
25
|
+
|
|
26
|
+
Pathname(i)
|
|
27
|
+
end
|
|
13
28
|
end
|
|
14
29
|
|
|
15
30
|
def references(&block)
|
|
@@ -19,7 +34,6 @@ module Fui
|
|
|
19
34
|
references[header] = []
|
|
20
35
|
end
|
|
21
36
|
Find.find(path) do |path|
|
|
22
|
-
next unless File.ftype(path) == 'file'
|
|
23
37
|
if ['.m', '.mm', '.h', '.pch'].include?(File.extname(path))
|
|
24
38
|
process_code references, path, &block
|
|
25
39
|
elsif ['.storyboard', '.xib'].include?(File.extname(path))
|
|
@@ -31,38 +45,62 @@ module Fui
|
|
|
31
45
|
end
|
|
32
46
|
|
|
33
47
|
def unused_references(&block)
|
|
34
|
-
@unused_references ||= references(&block).select { |
|
|
48
|
+
@unused_references ||= references(&block).select { |k, v| v.count.zero? && !bridging_headers.include?(k.filename) }
|
|
35
49
|
end
|
|
36
50
|
|
|
37
51
|
private
|
|
38
52
|
|
|
39
53
|
# Find all files for which the block yields.
|
|
40
|
-
def
|
|
54
|
+
def find(path)
|
|
41
55
|
results = []
|
|
42
56
|
Find.find(path) do |fpath|
|
|
57
|
+
if FileTest.directory?(fpath)
|
|
58
|
+
next unless ignores
|
|
59
|
+
|
|
60
|
+
ignores.each do |ignore|
|
|
61
|
+
next unless fpath.include?(ignore.realpath.to_s)
|
|
62
|
+
|
|
63
|
+
puts "Ignoring Directory: #{fpath}" if options[:verbose]
|
|
64
|
+
Find.prune
|
|
65
|
+
end
|
|
66
|
+
end
|
|
43
67
|
results << fpath if yield fpath
|
|
44
68
|
end
|
|
45
69
|
results
|
|
46
70
|
end
|
|
47
71
|
|
|
72
|
+
def local_imported(file_contents, header)
|
|
73
|
+
return false if options['ignore-local-imports']
|
|
74
|
+
|
|
75
|
+
file_contents.include?("#import \"#{header.filename}\"")
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def global_imported(file_contents, header)
|
|
79
|
+
return false if options['ignore-global-imports']
|
|
80
|
+
|
|
81
|
+
escaped_header = Regexp.quote(header.filename)
|
|
82
|
+
regex = '(#import\s{1}<.+\/' + escaped_header + '>)'
|
|
83
|
+
file_contents.match(regex)
|
|
84
|
+
end
|
|
85
|
+
|
|
48
86
|
def process_code(references, path)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
87
|
+
yield path if block_given?
|
|
88
|
+
file_contents = File.read(path, encoding: 'binary').encode('UTF-8', invalid: :replace, undef: :replace)
|
|
89
|
+
headers.each do |header|
|
|
90
|
+
filename_without_extension = File.basename(path, File.extname(path))
|
|
91
|
+
global_import_exists = global_imported(file_contents, header)
|
|
92
|
+
local_import_exists = local_imported(file_contents, header)
|
|
93
|
+
references[header] << path if filename_without_extension != header.filename_without_extension && (local_import_exists || global_import_exists)
|
|
56
94
|
end
|
|
57
95
|
end
|
|
58
96
|
|
|
59
97
|
def process_xml(references, path)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
98
|
+
yield path if block_given?
|
|
99
|
+
file_contents = File.read(path, encoding: 'binary').encode('UTF-8', invalid: :replace, undef: :replace)
|
|
100
|
+
headers.each do |header|
|
|
101
|
+
filename_without_extension = File.basename(path, File.extname(path))
|
|
102
|
+
check_xibs = !options['ignore-xib-files']
|
|
103
|
+
references[header] << path if (check_xibs || filename_without_extension != header.filename_without_extension) && file_contents.include?("customClass=\"#{header.filename_without_extension}\"")
|
|
66
104
|
end
|
|
67
105
|
end
|
|
68
106
|
end
|
data/lib/fui/header.rb
CHANGED
data/lib/fui/project.rb
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Fui
|
|
2
|
+
# Represents an Xcode Project pbxproj file
|
|
3
|
+
class Project
|
|
4
|
+
attr_accessor :filename, :bridging_header, :path
|
|
5
|
+
|
|
6
|
+
def self.project?(path)
|
|
7
|
+
File.extname(path) == '.pbxproj'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def initialize(path)
|
|
11
|
+
@path = path
|
|
12
|
+
@filename = File.basename(path)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def bridging_headers(verbose)
|
|
16
|
+
@bridging_headers ||= begin
|
|
17
|
+
regex = /(SWIFT_OBJC_BRIDGING_HEADER) = \".+\"/
|
|
18
|
+
bridging_headers = []
|
|
19
|
+
File.new(path).grep regex do |result|
|
|
20
|
+
tokens = result.split('"')
|
|
21
|
+
next if tokens.length < 2
|
|
22
|
+
|
|
23
|
+
path_tokens = tokens[1].split('/')
|
|
24
|
+
bridging_header = path_tokens[path_tokens.length - 1]
|
|
25
|
+
puts "Bridging Header Found: #{bridging_header} in #{path}." if verbose
|
|
26
|
+
bridging_headers << bridging_header
|
|
27
|
+
end
|
|
28
|
+
bridging_headers.uniq
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
data/lib/fui/version.rb
CHANGED
data/lib/fui.rb
CHANGED
metadata
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fui
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Doubrovkine
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-04-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: gli
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- -
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: '0'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- -
|
|
24
|
+
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '0'
|
|
27
|
-
description:
|
|
27
|
+
description:
|
|
28
28
|
email: dblock@dblock.org
|
|
29
29
|
executables:
|
|
30
30
|
- fui
|
|
@@ -35,33 +35,34 @@ files:
|
|
|
35
35
|
- CONTRIBUTING.md
|
|
36
36
|
- LICENSE.md
|
|
37
37
|
- README.md
|
|
38
|
+
- RELEASING.md
|
|
38
39
|
- bin/fui
|
|
39
40
|
- lib/fui.rb
|
|
40
41
|
- lib/fui/finder.rb
|
|
41
42
|
- lib/fui/header.rb
|
|
43
|
+
- lib/fui/project.rb
|
|
42
44
|
- lib/fui/version.rb
|
|
43
45
|
homepage: http://github.com/dblock/fui
|
|
44
46
|
licenses:
|
|
45
47
|
- MIT
|
|
46
48
|
metadata: {}
|
|
47
|
-
post_install_message:
|
|
49
|
+
post_install_message:
|
|
48
50
|
rdoc_options: []
|
|
49
51
|
require_paths:
|
|
50
52
|
- lib
|
|
51
53
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
52
54
|
requirements:
|
|
53
|
-
- -
|
|
55
|
+
- - ">="
|
|
54
56
|
- !ruby/object:Gem::Version
|
|
55
57
|
version: 1.9.3
|
|
56
58
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
59
|
requirements:
|
|
58
|
-
- -
|
|
60
|
+
- - ">="
|
|
59
61
|
- !ruby/object:Gem::Version
|
|
60
62
|
version: 1.3.6
|
|
61
63
|
requirements: []
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
signing_key:
|
|
64
|
+
rubygems_version: 3.5.16
|
|
65
|
+
signing_key:
|
|
65
66
|
specification_version: 4
|
|
66
67
|
summary: Find unused Objective-C imports.
|
|
67
68
|
test_files: []
|