fastlane-plugin-number_of_swift_lines 0.2.2 → 0.2.3

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
  SHA1:
3
- metadata.gz: 28b382290da720cf8a505bcbff1b3fbf47b837af
4
- data.tar.gz: f4301c68b87479423ab6de9e323cddc7de18b5af
3
+ metadata.gz: 0b0114eb4e4903ff288f3fc97fd64953ee9837db
4
+ data.tar.gz: b527d7b88ce41afe9ae19a8b61c584f679552bcf
5
5
  SHA512:
6
- metadata.gz: '08f5fe5d19b25030c86e81eb8170d56fe07b881bfbc3432e44c0c5b1c27868c60e1b54b382c00fb2e425e520180b73173e34965ad3c3fec43d81b5298d68a9e6'
7
- data.tar.gz: d8519282f2f3119a6224a18b8991489187a1ff8d0ae39a3f4031b794a90470fb7f8e6e3e8750160847f70bf82dc2a2e32bcc36118cc19d942783adc585e31167
6
+ metadata.gz: b15bc5040c379739bda57986da6302af4281d78f63eb3a943d287ccbc7c515c666e21c2840f539cb377f9290e1db0a33d80b535b73d7a3df9ff9e13d4dd57ccd
7
+ data.tar.gz: 30b0e8a2952b06ba0baf08ff294d6450080b99c88d363ee85fadd5abf7c3701b25bab495736753deafe3a23078eda980a056c6b3616b0be45d46eea2674e5ee5
@@ -4,6 +4,8 @@ module Fastlane
4
4
  NUMBER_OF_SWIFT_LINES_IN_LARGEST_FILES = :NUMBER_OF_SWIFT_LINES_IN_LARGEST_FILES
5
5
  NUMBER_OF_SWIFT_FILES = :NUMBER_OF_SWIFT_FILES
6
6
  NUMBER_OF_SWIFT_LINES = :NUMBER_OF_SWIFT_LINES
7
+ NUMBER_OF_SWIFT_TEST_FILES_LINES = :NUMBER_OF_SWIFT_TEST_FILES_LINES
8
+ TEST_PROD_CODE_RATIO = :TEST_PROD_CODE_RATIO
7
9
  end
8
10
 
9
11
  class NumberOfSwiftLinesAction < Action
@@ -13,10 +15,14 @@ module Fastlane
13
15
  number_of_largest_files = params[:largest_files_cap]
14
16
  show_ascii = params[:enable_ascii_art]
15
17
  exclude_regex = params[:files_exclude_regex]
18
+ include_regex = params[:test_files_include_regex]
19
+ #skip_empty = params[:skip_empty_lines]
16
20
 
17
21
  find_command = "find . -name \"*.swift\" | egrep -v \"#{exclude_regex}\""
22
+ find_command_tests = "find . -name \"*.swift\" | egrep \"#{include_regex}\""
18
23
  #find_command = "find . -name '*.swift' -not -path '*/Tests/*' -not -path '*/Pods/*' -not -path '*/Carthage/*' -print0"
19
24
  UI.message(find_command)
25
+ UI.message(find_command_tests)
20
26
 
21
27
  swift_files = `#{find_command}`
22
28
  if swift_files.empty?
@@ -24,33 +30,52 @@ module Fastlane
24
30
  exit 1
25
31
  end
26
32
 
33
+ test_files = `#{find_command_tests}`
34
+ number_of_lines_test_files = "0\n"
35
+ if test_files.empty?
36
+ UI.message("WARNING: No test files found :(")
37
+ else
38
+ number_of_lines_test_files = `echo '#{test_files}' | tr '\\n' '\\0' | xargs -0 wc -l | tail -1 | awk '{print $1}'`
39
+ end
40
+
41
+ # | xargs -0 awk 'NF > 0' | wc -l
27
42
  number_of_files = `echo '#{swift_files}' | wc -l | awk '{print $1}'`
28
43
  number_of_lines = `echo '#{swift_files}' | tr '\\n' '\\0' | xargs -0 wc -l | tail -1 | awk '{print $1}'`
29
44
  largest_files = `echo '#{swift_files}' | tr '\\n' '\\0' | xargs -0 wc -l | sort -n | tail -'#{number_of_largest_files.to_s}' | head -'#{(number_of_largest_files-1).to_s}'`
30
45
  number_of_lines_largest_file = `echo '#{swift_files}' | tr '\\n' '\\0' | xargs -0 wc -l | sort -n | tail -2 | head -1 | awk '{print $1}'`
31
46
 
47
+ test_production_code_ratio = number_of_lines_test_files.to_f / number_of_lines.to_f
48
+ test_production_code_ratio_str = test_production_code_ratio.round(2).to_s
49
+
32
50
  ascii_message = ""
33
51
  if show_ascii == true then
34
52
  a = Artii::Base.new :font => 'univers'
35
- ascii_message = a.asciify(number_of_lines_largest_file)
53
+ ascii_message = ""
54
+ ascii_message += a.asciify(number_of_lines_largest_file)
36
55
  ascii_message += a.asciify(number_of_files)
37
56
  ascii_message += a.asciify(number_of_lines)
57
+ ascii_message += a.asciify(number_of_lines_test_files)
58
+ ascii_message += a.asciify(test_production_code_ratio_str.to_s)
38
59
  end
39
60
 
40
61
  UI.message("\n\n" + "The " + number_of_largest_files.to_s + " largest files in ascending order:\n\n" + largest_files \
41
62
  + "\n\nNumber of lines in the largest swift file:\t" + number_of_lines_largest_file \
42
63
  + "Total number of swift files:\t\t\t" + number_of_files \
43
- + "Total number of swift lines of code:\t\t" + number_of_lines + "\n"\
44
- + ascii_message)
64
+ + "Total number of swift lines of code:\t\t" + number_of_lines \
65
+ + "Total number of swift lines in test files:\t" + number_of_lines_test_files \
66
+ + "Testing / Production code ratio:\t\t" + test_production_code_ratio_str.to_s + "\n\n\n"\
67
+ + ascii_message + "\n")
45
68
 
46
69
  Actions.lane_context[SharedValues::NUMBER_OF_SWIFT_LINES_IN_LARGEST_FILES] = number_of_lines_largest_file
47
70
  Actions.lane_context[SharedValues::NUMBER_OF_SWIFT_FILES] = number_of_files
48
71
  Actions.lane_context[SharedValues::NUMBER_OF_SWIFT_LINES] = number_of_lines
72
+ Actions.lane_context[SharedValues::NUMBER_OF_SWIFT_TEST_FILES_LINES] = number_of_lines_test_files
73
+ Actions.lane_context[SharedValues::TEST_PROD_CODE_RATIO] = test_production_code_ratio_str.to_s
49
74
 
50
75
  end
51
76
 
52
77
  def self.description
53
- "Outputs the total number of lines of swift code, number of swift files, and a list of the largest swift files."
78
+ "Outputs the total number of lines of swift code, number of swift files, and a list of the largest swift files, and some other useful statistics"
54
79
  end
55
80
 
56
81
  def self.authors
@@ -60,15 +85,18 @@ module Fastlane
60
85
  def self.return_value
61
86
  # If your method provides a return value, you can describe here what it does
62
87
  [
63
- ['NUMBER_OF_SWIFT_LINES_IN_LARGEST_FILES', 'The number of lines in the largets swift file'],
64
- ['NUMBER_OF_SWIFT_FILES', 'The total number of swift files'],
65
- ['NUMBER_OF_SWIFT_LINES', 'The total number of swift lines in all swift files']
88
+ ['NUMBER_OF_SWIFT_LINES_IN_LARGEST_FILES', 'The number of lines in the largets swift file, excluding testing files'],
89
+ ['NUMBER_OF_SWIFT_FILES', 'The total number of swift files, excluding testing files'],
90
+ ['NUMBER_OF_SWIFT_LINES', 'The total number of swift lines in all prodcution code swift files'],
91
+ ['NUMBER_OF_SWIFT_TEST_FILES_LINES', 'The total number of swift lines in all testing swift files'],
92
+ ['TEST_PROD_CODE_RATIO', 'The ratio between testing and production code in all swift files']
66
93
  ]
67
94
  end
68
95
 
69
96
  def self.details
70
97
  # Optional:
71
- "Using ASCII art to output the total number of code lines written in Swift, excluding all the lines used in unit & UI tests. But also outputs the total number of swift files and a list of the largest swift files."
98
+ "Outputs the total number of lines of swift code, number of swift files, and a list of the largest swift files, and some other useful statistics. \
99
+ Default optinos, excludes unit & UI testing swift files and outputs the statistics in ASCII art :)"
72
100
  end
73
101
 
74
102
  def self.available_options
@@ -87,11 +115,25 @@ module Fastlane
87
115
  default_value: true,
88
116
  type: [TrueClass, FalseClass]),
89
117
 
118
+ # FastlaneCore::ConfigItem.new(key: :skip_empty_lines,
119
+ # env_name: "SKIP_EMPTY_LINES",
120
+ # description: "If enabled, does not include empty lines in the statistics",
121
+ # optional: true,
122
+ # default_value: true,
123
+ # type: [TrueClass, FalseClass]),
124
+
90
125
  FastlaneCore::ConfigItem.new(key: :files_exclude_regex,
91
126
  env_name: "FILES_EXCLUDE_REGEX",
92
127
  description: "Regex string used with grep to exclude files from the list of all swift files",
93
128
  optional: true,
94
- default_value: "(/Tests|/Pods|/Carthage)",
129
+ default_value: "(/Test|/Pods|/Carthage)",
130
+ type: String),
131
+
132
+ FastlaneCore::ConfigItem.new(key: :test_files_include_regex,
133
+ env_name: "TEST_FILES_INCLUDE_REGEX",
134
+ description: "Regex string used with grep when searching for test files",
135
+ optional: true,
136
+ default_value: "/Test",
95
137
  type: String)
96
138
  ]
97
139
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module NumberOfSwiftLines
3
- VERSION = "0.2.2"
3
+ VERSION = "0.2.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-number_of_swift_lines
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Charmington
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-30 00:00:00.000000000 Z
11
+ date: 2017-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: artii
@@ -168,8 +168,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
168
  version: '0'
169
169
  requirements: []
170
170
  rubyforge_project:
171
- rubygems_version: 2.6.8
171
+ rubygems_version: 2.5.2
172
172
  signing_key:
173
173
  specification_version: 4
174
- summary: Outputs the total number of swift lines
174
+ summary: Outputs the total number of swift lines and other useful statistics
175
175
  test_files: []