danger-xcode_warnings 0.1.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bee619f39b0fd91e1cec3b021d23d79d5bdfca95272ed1625695e0f713057587
4
+ data.tar.gz: 5ec6b7d4429620ecfee75a8cd02225f47551f453d87e263555263fe2a966c4a2
5
+ SHA512:
6
+ metadata.gz: df7ef828a16ffbd853fff8bece28ddb304851279d063b6c5077aa674fa275def8fec8f10ddb73688ebc51d7e084a76ea21ac90a9a2f72eb004f2c312c54d74f6
7
+ data.tar.gz: 2db67e9ebd809bd986899c0b50cec34e3b690ff503d51b53f87ea94844e2ee282ac358d5c8557ccd84f3db831113dd216a1d98ab7a76898744f1a0950f8fc98c
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
4
+ .yardoc
data/.rubocop.yml ADDED
@@ -0,0 +1,152 @@
1
+ # Defaults can be found here: https://github.com/bbatsov/rubocop/blob/master/config/default.yml
2
+
3
+ # If you don't like these settings, just delete this file :)
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 2.3
7
+
8
+ Style/StringLiterals:
9
+ EnforcedStyle: double_quotes
10
+ Enabled: true
11
+
12
+ # kind_of? is a good way to check a type
13
+ Style/ClassCheck:
14
+ EnforcedStyle: kind_of?
15
+
16
+ # It's better to be more explicit about the type
17
+ Style/BracesAroundHashParameters:
18
+ Enabled: false
19
+
20
+ # specs sometimes have useless assignments, which is fine
21
+ Lint/UselessAssignment:
22
+ Exclude:
23
+ - '**/spec/**/*'
24
+
25
+ # We could potentially enable the 2 below:
26
+ Layout/IndentFirstHashElement:
27
+ Enabled: false
28
+
29
+ Layout/AlignHash:
30
+ Enabled: false
31
+
32
+ # HoundCI doesn't like this rule
33
+ Layout/DotPosition:
34
+ Enabled: false
35
+
36
+ # We allow !! as it's an easy way to convert ot boolean
37
+ Style/DoubleNegation:
38
+ Enabled: false
39
+
40
+ # Cop supports --auto-correct.
41
+ Lint/UnusedBlockArgument:
42
+ Enabled: false
43
+
44
+ # We want to allow class Fastlane::Class
45
+ Style/ClassAndModuleChildren:
46
+ Enabled: false
47
+
48
+ Metrics/AbcSize:
49
+ Max: 60
50
+
51
+ # The %w might be confusing for new users
52
+ Style/WordArray:
53
+ MinSize: 19
54
+
55
+ # raise and fail are both okay
56
+ Style/SignalException:
57
+ Enabled: false
58
+
59
+ # Better too much 'return' than one missing
60
+ Style/RedundantReturn:
61
+ Enabled: false
62
+
63
+ # Having if in the same line might not always be good
64
+ Style/IfUnlessModifier:
65
+ Enabled: false
66
+
67
+ # and and or is okay
68
+ Style/AndOr:
69
+ Enabled: false
70
+
71
+ # Configuration parameters: CountComments.
72
+ Metrics/ClassLength:
73
+ Max: 350
74
+
75
+ Metrics/CyclomaticComplexity:
76
+ Max: 17
77
+
78
+ # Configuration parameters: AllowURI, URISchemes.
79
+ Metrics/LineLength:
80
+ Max: 370
81
+
82
+ # Configuration parameters: CountKeywordArgs.
83
+ Metrics/ParameterLists:
84
+ Max: 10
85
+
86
+ Metrics/PerceivedComplexity:
87
+ Max: 18
88
+
89
+ # Sometimes it's easier to read without guards
90
+ Style/GuardClause:
91
+ Enabled: false
92
+
93
+ # something = if something_else
94
+ # that's confusing
95
+ Style/ConditionalAssignment:
96
+ Enabled: false
97
+
98
+ # Better to have too much self than missing a self
99
+ Style/RedundantSelf:
100
+ Enabled: false
101
+
102
+ Metrics/MethodLength:
103
+ Max: 60
104
+
105
+ # We're not there yet
106
+ Style/Documentation:
107
+ Enabled: false
108
+
109
+ # Adds complexity
110
+ Style/IfInsideElse:
111
+ Enabled: false
112
+
113
+ Style/FrozenStringLiteralComment:
114
+ Enabled: false
115
+
116
+ # danger specific
117
+
118
+ Style/BlockComments:
119
+ Enabled: false
120
+
121
+ Layout/MultilineMethodCallIndentation:
122
+ EnforcedStyle: indented
123
+
124
+ # FIXME: 25
125
+ Metrics/BlockLength:
126
+ Max: 345
127
+ Exclude:
128
+ - "**/*_spec.rb"
129
+
130
+ Style/MixinGrouping:
131
+ Enabled: false
132
+
133
+ Layout/IndentHeredoc:
134
+ Enabled: false
135
+
136
+ Style/SpecialGlobalVars:
137
+ Enabled: false
138
+
139
+ PercentLiteralDelimiters:
140
+ PreferredDelimiters:
141
+ "%": ()
142
+ "%i": ()
143
+ "%q": ()
144
+ "%Q": ()
145
+ "%r": "{}"
146
+ "%s": ()
147
+ "%w": ()
148
+ "%W": ()
149
+ "%x": ()
150
+
151
+ Security/YAMLLoad:
152
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,16 @@
1
+ language: ruby
2
+ cache:
3
+ directories:
4
+ - bundle
5
+
6
+ rvm:
7
+ - 2.3.1
8
+ - 2.4.1
9
+ - 2.5.1
10
+
11
+ branches:
12
+ only:
13
+ - master
14
+
15
+ script:
16
+ - bundle exec rake spec
@@ -0,0 +1,3 @@
1
+ {
2
+ "ruby.format": "rubocop"
3
+ }
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in danger-xcode_warnings.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,137 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ danger-xcode_warnings (0.1.2)
5
+ danger-plugin-api (~> 1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.6.0)
11
+ public_suffix (>= 2.0.2, < 4.0)
12
+ ast (2.4.0)
13
+ claide (1.0.2)
14
+ claide-plugins (0.9.2)
15
+ cork
16
+ nap
17
+ open4 (~> 1.3)
18
+ coderay (1.1.2)
19
+ colored2 (3.1.2)
20
+ cork (0.3.0)
21
+ colored2 (~> 3.1)
22
+ danger (6.0.9)
23
+ claide (~> 1.0)
24
+ claide-plugins (>= 0.9.2)
25
+ colored2 (~> 3.1)
26
+ cork (~> 0.1)
27
+ faraday (~> 0.9)
28
+ faraday-http-cache (~> 2.0)
29
+ git (~> 1.5)
30
+ kramdown (~> 2.0)
31
+ kramdown-parser-gfm (~> 1.0)
32
+ no_proxy_fix
33
+ octokit (~> 4.7)
34
+ terminal-table (~> 1)
35
+ danger-plugin-api (1.0.0)
36
+ danger (> 2.0)
37
+ diff-lcs (1.3)
38
+ faraday (0.15.4)
39
+ multipart-post (>= 1.2, < 3)
40
+ faraday-http-cache (2.0.0)
41
+ faraday (~> 0.8)
42
+ ffi (1.11.1)
43
+ formatador (0.2.5)
44
+ git (1.5.0)
45
+ guard (2.15.0)
46
+ formatador (>= 0.2.4)
47
+ listen (>= 2.7, < 4.0)
48
+ lumberjack (>= 1.0.12, < 2.0)
49
+ nenv (~> 0.1)
50
+ notiffany (~> 0.0)
51
+ pry (>= 0.9.12)
52
+ shellany (~> 0.0)
53
+ thor (>= 0.18.1)
54
+ guard-compat (1.2.1)
55
+ guard-rspec (4.7.3)
56
+ guard (~> 2.1)
57
+ guard-compat (~> 1.1)
58
+ rspec (>= 2.99.0, < 4.0)
59
+ jaro_winkler (1.5.3)
60
+ kramdown (2.1.0)
61
+ kramdown-parser-gfm (1.1.0)
62
+ kramdown (~> 2.0)
63
+ listen (3.0.7)
64
+ rb-fsevent (>= 0.9.3)
65
+ rb-inotify (>= 0.9.7)
66
+ lumberjack (1.0.13)
67
+ method_source (0.9.2)
68
+ multipart-post (2.1.1)
69
+ nap (1.1.0)
70
+ nenv (0.3.0)
71
+ no_proxy_fix (0.1.2)
72
+ notiffany (0.1.1)
73
+ nenv (~> 0.1)
74
+ shellany (~> 0.0)
75
+ octokit (4.14.0)
76
+ sawyer (~> 0.8.0, >= 0.5.3)
77
+ open4 (1.3.4)
78
+ parallel (1.17.0)
79
+ parser (2.6.3.0)
80
+ ast (~> 2.4.0)
81
+ pry (0.12.2)
82
+ coderay (~> 1.1.0)
83
+ method_source (~> 0.9.0)
84
+ public_suffix (3.1.1)
85
+ rainbow (3.0.0)
86
+ rake (10.5.0)
87
+ rb-fsevent (0.10.3)
88
+ rb-inotify (0.10.0)
89
+ ffi (~> 1.0)
90
+ rspec (3.8.0)
91
+ rspec-core (~> 3.8.0)
92
+ rspec-expectations (~> 3.8.0)
93
+ rspec-mocks (~> 3.8.0)
94
+ rspec-core (3.8.2)
95
+ rspec-support (~> 3.8.0)
96
+ rspec-expectations (3.8.4)
97
+ diff-lcs (>= 1.2.0, < 2.0)
98
+ rspec-support (~> 3.8.0)
99
+ rspec-mocks (3.8.1)
100
+ diff-lcs (>= 1.2.0, < 2.0)
101
+ rspec-support (~> 3.8.0)
102
+ rspec-support (3.8.2)
103
+ rubocop (0.72.0)
104
+ jaro_winkler (~> 1.5.1)
105
+ parallel (~> 1.10)
106
+ parser (>= 2.6)
107
+ rainbow (>= 2.2.2, < 4.0)
108
+ ruby-progressbar (~> 1.7)
109
+ unicode-display_width (>= 1.4.0, < 1.7)
110
+ ruby-progressbar (1.10.1)
111
+ sawyer (0.8.2)
112
+ addressable (>= 2.3.5)
113
+ faraday (> 0.8, < 2.0)
114
+ shellany (0.0.1)
115
+ terminal-table (1.8.0)
116
+ unicode-display_width (~> 1.1, >= 1.1.1)
117
+ thor (0.20.3)
118
+ unicode-display_width (1.6.0)
119
+ yard (0.9.20)
120
+
121
+ PLATFORMS
122
+ ruby
123
+
124
+ DEPENDENCIES
125
+ bundler (~> 1.3)
126
+ danger-xcode_warnings!
127
+ guard (~> 2.14)
128
+ guard-rspec (~> 4.7)
129
+ listen (= 3.0.7)
130
+ pry
131
+ rake (~> 10.0)
132
+ rspec (~> 3.4)
133
+ rubocop
134
+ yard
135
+
136
+ BUNDLED WITH
137
+ 1.16.2
data/Guardfile ADDED
@@ -0,0 +1,19 @@
1
+ # A guardfile for making Danger Plugins
2
+ # For more info see https://github.com/guard/guard#readme
3
+
4
+ # To run, use `bundle exec guard`.
5
+
6
+ guard :rspec, cmd: 'bundle exec rspec' do
7
+ require 'guard/rspec/dsl'
8
+ dsl = Guard::RSpec::Dsl.new(self)
9
+
10
+ # RSpec files
11
+ rspec = dsl.rspec
12
+ watch(rspec.spec_helper) { rspec.spec_dir }
13
+ watch(rspec.spec_support) { rspec.spec_dir }
14
+ watch(rspec.spec_files)
15
+
16
+ # Ruby files
17
+ ruby = dsl.ruby
18
+ dsl.watch_spec_files_for(ruby.lib_files)
19
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2019 Suita Fujino
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # danger-xcode_warnings
2
+
3
+ [![version](https://img.shields.io/badge/version-0.1.0-blue.svg)](https://github.com/Scior/Linna)
4
+ [![Build Status](https://travis-ci.org/Scior/danger-xcode_warnings.svg?branch=master)](https://travis-ci.org/Scior/danger-xcode_warnings)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ A Danger plugin to show warnings from xcodebuild.
8
+
9
+ ## Installation
10
+
11
+ ```sh
12
+ gem install specific_install
13
+ gem specific_install git@github.com:Scior/danger-xcode_warnings.git
14
+ ```
15
+
16
+ Or using Bundler,
17
+
18
+ ```ruby
19
+ gem 'danger-xcode_warnings', :git => 'https://github.com/Scior/danger-xcode_warnings.git'
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ Simply collect the log from `xcodebuild`,
25
+
26
+ ```sh
27
+ xcodebuild clean build >> buildlog.log
28
+ ```
29
+
30
+ and analyze on your `Dangerfile`.
31
+
32
+ ```ruby
33
+ xcode_warnings.analyze_file 'buildlog.log'
34
+ ```
35
+
36
+ ## Development
37
+
38
+ 1. Clone this repo
39
+ 2. Run `bundle install` to setup dependencies.
40
+ 3. Run `bundle exec rake spec` to run the tests.
41
+ 4. Use `bundle exec guard` to automatically have tests run as you make changes.
42
+ 5. Make your changes.
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:specs)
6
+
7
+ task default: :specs
8
+
9
+ task :spec do
10
+ Rake::Task['specs'].invoke
11
+ Rake::Task['rubocop'].invoke
12
+ Rake::Task['spec_docs'].invoke
13
+ end
14
+
15
+ desc 'Run RuboCop on the lib/specs directory'
16
+ RuboCop::RakeTask.new(:rubocop) do |task|
17
+ task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
18
+ end
19
+
20
+ desc 'Ensure that the plugin passes `danger plugins lint`'
21
+ task :spec_docs do
22
+ sh 'bundle exec danger plugins lint'
23
+ end
@@ -0,0 +1,49 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'xcode_warnings/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'danger-xcode_warnings'
8
+ spec.version = XcodeWarnings::VERSION
9
+ spec.authors = ['Scior']
10
+ spec.email = ['interval12@gmail.com']
11
+ spec.description = "Show Xcode warnings with Danger"
12
+ spec.summary = "Show Xcode warnings with Danger"
13
+ spec.homepage = 'https://github.com/Scior/danger-xcode_warnings'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
22
+
23
+ # General ruby development
24
+ spec.add_development_dependency 'bundler', '~> 1.3'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+
27
+ # Testing support
28
+ spec.add_development_dependency 'rspec', '~> 3.4'
29
+
30
+ # Linting code and docs
31
+ spec.add_development_dependency "rubocop"
32
+ spec.add_development_dependency "yard"
33
+
34
+ # Makes testing easy via `bundle exec guard`
35
+ spec.add_development_dependency 'guard', '~> 2.14'
36
+ spec.add_development_dependency 'guard-rspec', '~> 4.7'
37
+
38
+ # If you want to work on older builds of ruby
39
+ spec.add_development_dependency 'listen', '3.0.7'
40
+
41
+ # This gives you the chance to run a REPL inside your tests
42
+ # via:
43
+ #
44
+ # require 'pry'
45
+ # binding.pry
46
+ #
47
+ # This will stop test execution and let you inspect the results
48
+ spec.add_development_dependency 'pry'
49
+ end
@@ -0,0 +1 @@
1
+ require "xcode_warnings/plugin"
@@ -0,0 +1 @@
1
+ require "xcode_warnings/gem_version"
@@ -0,0 +1,3 @@
1
+ module XcodeWarnings
2
+ VERSION = "0.1.2".freeze
3
+ end
@@ -0,0 +1,68 @@
1
+ #
2
+ # Parser for the xcodebuild log.
3
+ #
4
+ class LogParser
5
+ # The keyword for detecing warnings.
6
+ KEYWORD_WARNING = " warning: ".freeze
7
+
8
+ # Struct represents warnings.
9
+ Warning = Struct.new(:file, :line, :message)
10
+
11
+ # Whether show build warnings or not.
12
+ # @return [void]
13
+ attr_accessor :show_build_warnings
14
+
15
+ # Whether show linker warnings or not.
16
+ # @return [void]
17
+ attr_accessor :show_linker_warnings
18
+
19
+ # Whether show build timing summary or not.
20
+ # @return [void]
21
+ attr_accessor :show_build_timing_summary
22
+
23
+ # Parses the log text into array of Warnings.
24
+ #
25
+ # @param [String] text The text to parse.
26
+ # @return [Array] Array of `Warning`.
27
+ #
28
+ def parse_warnings(text)
29
+ warning_texts = text.each_line.select { |s| s.include?(KEYWORD_WARNING) }.uniq
30
+ warning_texts.map! { |s| parse_warning_text(s) }.compact
31
+ end
32
+
33
+ # Parses the log text into a build timing summary message.
34
+ #
35
+ # @param [String] text The text to parse.
36
+ # @return [String] Message of build timing summary.
37
+ #
38
+ def parse_build_timing_summary(text)
39
+ return nil unless @show_build_timing_summary
40
+
41
+ lines = text.lines.map!(&:chomp)
42
+ index = lines.index("Build Timing Summary")
43
+ return nil if index.nil?
44
+
45
+ lines[index + 1..-1].select { |s| s =~ /.+/ }.join("\n")
46
+ end
47
+
48
+ private
49
+
50
+ def parse_warning_text(text)
51
+ puts text
52
+ position, message = text.split(KEYWORD_WARNING)
53
+ if position.start_with?("ld")
54
+ # Linker warning
55
+ return nil unless @show_linker_warnings
56
+
57
+ return Warning.new(nil, nil, message.chomp)
58
+ end
59
+
60
+ # Build warnings
61
+ return nil unless @show_build_warnings
62
+
63
+ path, line, _column = position.split(":")
64
+ return nil if path.nil?
65
+
66
+ Warning.new(path.gsub("#{Dir.pwd}/", ""), line, message.chomp)
67
+ end
68
+ end
@@ -0,0 +1,20 @@
1
+ #
2
+ # Formatter for parsed warnings.
3
+ #
4
+ class MessageFormatter
5
+ # Format an item to text for Danger.
6
+ #
7
+ # @param [Warning] An item to format.
8
+ # @return [String] Formatted text.
9
+ #
10
+ def format(item)
11
+ file = item[:file]
12
+ line = item[:line]
13
+ message = item[:message]
14
+ if file.nil? || line.nil?
15
+ message
16
+ else
17
+ "**#{file}#L#{line}** #{message}"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,80 @@
1
+ require_relative "./log_parser"
2
+ require_relative "./message_formatter"
3
+
4
+ module Danger
5
+ # Parse the xcodebuild log file and convert warnings.
6
+ # @example Parse and show xcodebuild warnings.
7
+ #
8
+ # danger-xcode_warnings.analyze_file 'logfile'
9
+ #
10
+ # @see Scior/danger-xcode_warnings
11
+ #
12
+ class DangerXcodeWarnings < Plugin
13
+ # Whether show build warnings or not.
14
+ # @return [void]
15
+ attr_accessor :show_build_warnings
16
+
17
+ # Whether show linker warnings or not.
18
+ # @return [void]
19
+ attr_accessor :show_linker_warnings
20
+
21
+ # Whether show build timing summary or not.
22
+ # @return [void]
23
+ attr_accessor :show_build_timing_summary
24
+
25
+ # rubocop:disable Lint/DuplicateMethods
26
+ def show_build_warnings
27
+ @show_build_warnings.nil? ? true : @show_build_warnings
28
+ end
29
+
30
+ def show_linker_warnings
31
+ @show_linker_warnings || false
32
+ end
33
+
34
+ def show_build_timing_summary
35
+ @show_build_timing_summary || false
36
+ end
37
+ # rubocop:enable Lint/DuplicateMethods
38
+
39
+ # Parses the log text from xcodebuild and show warnings.
40
+ #
41
+ # @param [String] log_text Raw build log text.
42
+ # @param [Boolean] inline Whether leave comments inline or not.
43
+ # @param [Boolean] sticky Whether use sticky flag or not.
44
+ # @return [void]
45
+ #
46
+ def analyze(log_text, inline: false, sticky: true)
47
+ parser = LogParser.new
48
+ parser.show_build_warnings = show_build_warnings
49
+ parser.show_linker_warnings = show_linker_warnings
50
+ parser.show_build_timing_summary = show_build_timing_summary
51
+
52
+ parsed = parser.parse_warnings(log_text)
53
+ parsed.each do |warning|
54
+ if inline
55
+ warn(warning[:message], sticky: sticky, file: warning[:file], line: warning[:line])
56
+ else
57
+ warn MessageFormatter.new.format(warning)
58
+ end
59
+ end
60
+ message "Detected #{parsed.count} build-time warnings." unless parsed.empty?
61
+ message parser.parse_build_timing_summary(log_text)
62
+ end
63
+
64
+ # Parses the log file from xcodebuild and show warnings.
65
+ #
66
+ # @param [String] file_path Path for the log file.
67
+ # @param [Boolean] inline Whether leave comments inline or not.
68
+ # @param [Boolean] sticky Whether use sticky flag or not.
69
+ # @return [void]
70
+ #
71
+ def analyze_file(file_path, inline: false, sticky: true)
72
+ File.open(file_path) do |f|
73
+ puts "Opened #{file_path}"
74
+ analyze(f.read, inline: inline, sticky: sticky)
75
+ end
76
+ rescue Errno::ENOENT, Errno::EACCES => e
77
+ puts "Couldn't open the file: #{e}"
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,36 @@
1
+ User defaults from command line:
2
+ destination = platform=iOS Simulator,name=iPhone 8
3
+
4
+ note: Using new build system
5
+
6
+ ** CLEAN SUCCEEDED **
7
+
8
+ note: Using new build system
9
+ note: Planning build
10
+ note: Constructing build description
11
+ CreateBuildDirectory /Users/fujino/Library/Developer/Xcode/DerivedData/ColorStock-dhqarewkfxlxgbejuyhqpnwbvuqx/Build/Products (in target: ColorStock)
12
+ cd /Users/fujino/iOS/ColorStock
13
+ builtin-create-build-directory /Users/fujino/Library/Developer/Xcode/DerivedData/ColorStock-dhqarewkfxlxgbejuyhqpnwbvuqx/Build/Products
14
+
15
+ CreateBuildDirectory /Users/fujino/Library/Developer/Xcode/DerivedData/ColorStock-dhqarewkfxlxgbejuyhqpnwbvuqx/Build/Intermediates.noindex (in target: ColorStock)
16
+ cd /Users/fujino/iOS/ColorStock
17
+ builtin-create-build-directory /Users/fujino/Library/Developer/Xcode/DerivedData/ColorStock-dhqarewkfxlxgbejuyhqpnwbvuqx/Build/Intermediates.noindex
18
+
19
+ ld: warning: linking against a dylib which is not safe for use in application extensions: /hoge
20
+
21
+ /Users/fujino/iOS/ColorStock/ColorStock/Utility/Extension/UIColor+.swift:13:17: warning: initializer 'init(r:g:b:)' took 177ms to type-check (limit: 100ms)
22
+ convenience init(r: UInt8, g: UInt8, b: UInt8) {
23
+ ^
24
+ /Users/fujino/iOS/ColorStock/ColorStock/Presentation/ViewModel/Implementation/ColorSelectorViewModel.swift:75:10: warning: instance method 'makeFlowLayout(with:)' took 104ms to type-check (limit: 100ms)
25
+ func makeFlowLayout(with size: CGSize) -> UICollectionViewFlowLayout {
26
+ ^
27
+ /Users/fujino/iOS/ColorStock/ColorStock/Utility/Extension/UIColor+.swift:13:17: warning: initializer 'init(r:g:b:)' took 177ms to type-check (limit: 100ms)
28
+ convenience init(r: UInt8, g: UInt8, b: UInt8) {
29
+ ^
30
+ /Users/fujino/iOS/ColorStock/ColorStock/Presentation/ViewModel/Implementation/ColorSelectorViewModel.swift:75:10: warning: instance method 'makeFlowLayout(with:)' took 104ms to type-check (limit: 100ms)
31
+ func makeFlowLayout(with size: CGSize) -> UICollectionViewFlowLayout {
32
+ ^
33
+ /Users/fujino/iOS/ColorStock/ColorStock/Data/Entity/Color.swift:22:13: warning: variable 'hoge' was never used; consider replacing with '_' or removing it
34
+ var hoge: String?
35
+ ^~~~
36
+ _
@@ -0,0 +1,29 @@
1
+ User defaults from command line:
2
+ destination = platform=iOS Simulator,name=iPhone 8
3
+
4
+ note: Using new build system
5
+
6
+ ** CLEAN SUCCEEDED **
7
+
8
+ note: Using new build system
9
+ note: Planning build
10
+ note: Constructing build description
11
+ CreateBuildDirectory /Users/fujino/Library/Developer/Xcode/DerivedData/ColorStock-dhqarewkfxlxgbejuyhqpnwbvuqx/Build/Products (in target: ColorStock)
12
+ cd /Users/fujino/iOS/ColorStock
13
+ builtin-create-build-directory /Users/fujino/Library/Developer/Xcode/DerivedData/ColorStock-dhqarewkfxlxgbejuyhqpnwbvuqx/Build/Products
14
+
15
+ CreateBuildDirectory /Users/fujino/Library/Developer/Xcode/DerivedData/ColorStock-dhqarewkfxlxgbejuyhqpnwbvuqx/Build/Intermediates.noindex (in target: ColorStock)
16
+ cd /Users/fujino/iOS/ColorStock
17
+ builtin-create-build-directory /Users/fujino/Library/Developer/Xcode/DerivedData/ColorStock-dhqarewkfxlxgbejuyhqpnwbvuqx/Build/Intermediates.noindex
18
+
19
+ ld: warning: linking against a dylib which is not safe for use in application extensions: /hoge
20
+
21
+ Build Timing Summary
22
+
23
+ CompileStoryboard (2 tasks) | 10.000 seconds
24
+
25
+ CompileSwiftSources (1 task) | 2.000 seconds
26
+
27
+ Ld (1 task) | 0.000 seconds
28
+
29
+ LinkStoryboards (1 task) | 0.000 seconds
@@ -0,0 +1,17 @@
1
+ User defaults from command line:
2
+ destination = platform=iOS Simulator,name=iPhone 8
3
+
4
+ note: Using new build system
5
+
6
+ ** CLEAN SUCCEEDED **
7
+
8
+ note: Using new build system
9
+ note: Planning build
10
+ note: Constructing build description
11
+ CreateBuildDirectory /Users/fujino/Library/Developer/Xcode/DerivedData/ColorStock-dhqarewkfxlxgbejuyhqpnwbvuqx/Build/Products (in target: ColorStock)
12
+ cd /Users/fujino/iOS/ColorStock
13
+ builtin-create-build-directory /Users/fujino/Library/Developer/Xcode/DerivedData/ColorStock-dhqarewkfxlxgbejuyhqpnwbvuqx/Build/Products
14
+
15
+ CreateBuildDirectory /Users/fujino/Library/Developer/Xcode/DerivedData/ColorStock-dhqarewkfxlxgbejuyhqpnwbvuqx/Build/Intermediates.noindex (in target: ColorStock)
16
+ cd /Users/fujino/iOS/ColorStock
17
+ builtin-create-build-directory /Users/fujino/Library/Developer/Xcode/DerivedData/ColorStock-dhqarewkfxlxgbejuyhqpnwbvuqx/Build/Intermediates.noindex
@@ -0,0 +1,65 @@
1
+ require "pathname"
2
+ ROOT = Pathname.new(File.expand_path("..", __dir__))
3
+ $:.unshift((ROOT + "lib").to_s)
4
+ $:.unshift((ROOT + "spec").to_s)
5
+
6
+ require "bundler/setup"
7
+ require "pry"
8
+
9
+ require "rspec"
10
+ require "danger"
11
+
12
+ if `git remote -v` == ""
13
+ puts "You cannot run tests without setting a local git remote on this repo"
14
+ puts "It's a weird side-effect of Danger's internals."
15
+ exit(0)
16
+ end
17
+
18
+ # Use coloured output, it's the best.
19
+ RSpec.configure do |config|
20
+ config.filter_gems_from_backtrace "bundler"
21
+ config.color = true
22
+ config.tty = true
23
+ end
24
+
25
+ require "danger_plugin"
26
+
27
+ # These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
28
+ # If you are expanding these files, see if it's already been done ^.
29
+
30
+ # A silent version of the user interface,
31
+ # it comes with an extra function `.string` which will
32
+ # strip all ANSI colours from the string.
33
+
34
+ # rubocop:disable Lint/NestedMethodDefinition
35
+ def testing_ui
36
+ @output = StringIO.new
37
+ def @output.winsize
38
+ [20, 9999]
39
+ end
40
+
41
+ cork = Cork::Board.new(out: @output)
42
+ def cork.string
43
+ out.string.gsub(/\e\[([;\d]+)?m/, "")
44
+ end
45
+ cork
46
+ end
47
+ # rubocop:enable Lint/NestedMethodDefinition
48
+
49
+ # Example environment (ENV) that would come from
50
+ # running a PR on TravisCI
51
+ def testing_env
52
+ {
53
+ "HAS_JOSH_K_SEAL_OF_APPROVAL" => "true",
54
+ "TRAVIS_PULL_REQUEST" => "800",
55
+ "TRAVIS_REPO_SLUG" => "artsy/eigen",
56
+ "TRAVIS_COMMIT_RANGE" => "759adcbd0d8f...13c4dc8bb61d",
57
+ "DANGER_GITHUB_API_TOKEN" => "123sbdq54erfsd3422gdfio"
58
+ }
59
+ end
60
+
61
+ # A stubbed out Dangerfile for use in tests
62
+ def testing_dangerfile
63
+ env = Danger::EnvironmentManager.new(testing_env)
64
+ Danger::Dangerfile.new(env, testing_ui)
65
+ end
@@ -0,0 +1,81 @@
1
+ require File.expand_path("spec_helper", __dir__)
2
+
3
+ module Danger
4
+ describe Danger::DangerXcodeWarnings do
5
+ it "should be a plugin" do
6
+ expect(Danger::DangerXcodeWarnings.new(nil)).to be_a Danger::Plugin
7
+ end
8
+
9
+ #
10
+ # You should test your custom attributes and methods here
11
+ #
12
+ describe "with Dangerfile" do
13
+ before do
14
+ @dangerfile = testing_dangerfile
15
+ @xcode_warnings = @dangerfile.xcode_warnings
16
+ end
17
+
18
+ it "Warns 3 lines with default settings" do
19
+ @xcode_warnings.analyze_file "spec/fixtures/log_with_4_errors"
20
+
21
+ expect(@dangerfile.status_report[:warnings]).to eq [
22
+ "**/Users/fujino/iOS/ColorStock/ColorStock/Utility/Extension/UIColor+.swift#L13** initializer 'init(r:g:b:)' took 177ms to type-check (limit: 100ms)",
23
+ "**/Users/fujino/iOS/ColorStock/ColorStock/Presentation/ViewModel/Implementation/ColorSelectorViewModel.swift#L75** instance method 'makeFlowLayout(with:)' took 104ms to type-check (limit: 100ms)",
24
+ "**/Users/fujino/iOS/ColorStock/ColorStock/Data/Entity/Color.swift#L22** variable 'hoge' was never used; consider replacing with '_' or removing it"
25
+ ]
26
+ expect(@dangerfile.status_report[:messages]).to eq [
27
+ "Detected 3 build-time warnings."
28
+ ]
29
+ end
30
+
31
+ it "Warns 4 lines with all settings enabled" do
32
+ @xcode_warnings.show_build_warnings = true
33
+ @xcode_warnings.show_linker_warnings = true
34
+ @xcode_warnings.analyze_file "spec/fixtures/log_with_4_errors"
35
+
36
+ expect(@dangerfile.status_report[:warnings]).to eq [
37
+ "linking against a dylib which is not safe for use in application extensions: /hoge",
38
+ "**/Users/fujino/iOS/ColorStock/ColorStock/Utility/Extension/UIColor+.swift#L13** initializer 'init(r:g:b:)' took 177ms to type-check (limit: 100ms)",
39
+ "**/Users/fujino/iOS/ColorStock/ColorStock/Presentation/ViewModel/Implementation/ColorSelectorViewModel.swift#L75** instance method 'makeFlowLayout(with:)' took 104ms to type-check (limit: 100ms)",
40
+ "**/Users/fujino/iOS/ColorStock/ColorStock/Data/Entity/Color.swift#L22** variable 'hoge' was never used; consider replacing with '_' or removing it"
41
+ ]
42
+ expect(@dangerfile.status_report[:messages]).to eq [
43
+ "Detected 4 build-time warnings."
44
+ ]
45
+ end
46
+
47
+ it "Doesn't warn lines with all settings disabled" do
48
+ @xcode_warnings.show_build_warnings = false
49
+ @xcode_warnings.show_linker_warnings = false
50
+ @xcode_warnings.analyze_file "spec/fixtures/log_with_4_errors"
51
+
52
+ expect(@dangerfile.status_report[:warnings]).to eq []
53
+ expect(@dangerfile.status_report[:messages]).to eq []
54
+ end
55
+
56
+ it "Show build timing summary" do
57
+ @xcode_warnings.show_build_timing_summary = true
58
+ @xcode_warnings.analyze_file "spec/fixtures/log_with_build_timing_summary"
59
+
60
+ expect(@dangerfile.status_report[:warnings]).to eq []
61
+ expect(@dangerfile.status_report[:messages]).to eq [
62
+ "CompileStoryboard (2 tasks) | 10.000 seconds\n" \
63
+ "CompileSwiftSources (1 task) | 2.000 seconds\n" \
64
+ "Ld (1 task) | 0.000 seconds\n" \
65
+ "LinkStoryboards (1 task) | 0.000 seconds"
66
+ ]
67
+ end
68
+
69
+ it "Doesn't warn with the clean build log" do
70
+ @xcode_warnings.analyze_file "spec/fixtures/log_without_error"
71
+
72
+ expect(@dangerfile.status_report[:warnings]).to eq []
73
+ expect(@dangerfile.status_report[:messages]).to eq []
74
+ end
75
+
76
+ it "Couldn't find the file" do
77
+ @xcode_warnings.analyze_file "spec/fixtures/hoge"
78
+ end
79
+ end
80
+ end
81
+ end
metadata ADDED
@@ -0,0 +1,211 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: danger-xcode_warnings
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Scior
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-07-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: danger-plugin-api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
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
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: yard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.14'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.14'
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '4.7'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '4.7'
125
+ - !ruby/object:Gem::Dependency
126
+ name: listen
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 3.0.7
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 3.0.7
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description: Show Xcode warnings with Danger
154
+ email:
155
+ - interval12@gmail.com
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - ".gitignore"
161
+ - ".rubocop.yml"
162
+ - ".travis.yml"
163
+ - ".vscode/settings.json"
164
+ - Gemfile
165
+ - Gemfile.lock
166
+ - Guardfile
167
+ - LICENSE.txt
168
+ - README.md
169
+ - Rakefile
170
+ - danger-xcode_warnings.gemspec
171
+ - lib/danger_plugin.rb
172
+ - lib/danger_xcode_warnings.rb
173
+ - lib/xcode_warnings/gem_version.rb
174
+ - lib/xcode_warnings/log_parser.rb
175
+ - lib/xcode_warnings/message_formatter.rb
176
+ - lib/xcode_warnings/plugin.rb
177
+ - spec/fixtures/log_with_4_errors
178
+ - spec/fixtures/log_with_build_timing_summary
179
+ - spec/fixtures/log_without_error
180
+ - spec/spec_helper.rb
181
+ - spec/xcode_warnings_spec.rb
182
+ homepage: https://github.com/Scior/danger-xcode_warnings
183
+ licenses:
184
+ - MIT
185
+ metadata: {}
186
+ post_install_message:
187
+ rdoc_options: []
188
+ require_paths:
189
+ - lib
190
+ required_ruby_version: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ required_rubygems_version: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - ">="
198
+ - !ruby/object:Gem::Version
199
+ version: '0'
200
+ requirements: []
201
+ rubyforge_project:
202
+ rubygems_version: 2.7.6
203
+ signing_key:
204
+ specification_version: 4
205
+ summary: Show Xcode warnings with Danger
206
+ test_files:
207
+ - spec/fixtures/log_with_4_errors
208
+ - spec/fixtures/log_with_build_timing_summary
209
+ - spec/fixtures/log_without_error
210
+ - spec/spec_helper.rb
211
+ - spec/xcode_warnings_spec.rb