marklarr / mayday Goto Github PK
View Code? Open in Web Editor NEWEasily add custom warnings and errors to your Xcode project's build process
License: MIT License
Easily add custom warnings and errors to your Xcode project's build process
License: MIT License
Hey @marklarr, thanks for Mayday. Everyone at work is loving it ;)
I was wondering if you would be open to adding line-by-line warnings and errors that are easier to use than regex, like:
# Throws a warning when "// Copyright (c)" is found on any line in a file
error_present "// Copyright (c)"
The copyright boilerplate, TODO, and FIXME are three cases in which I'd love to add a really quick warning or error but don't want to make sure my regex is correct. What do you think?
OK I'm not a big ruby fan so I kinda suck at this but I wanted to use StringScanner to, well, scan a line so I required it in my MaydayFile, using require 'strscan'
. I noticed that it doesn't work tough because of the way Mayday creates the "Generate Mayday Flags".
Any workaround ?
We currently have 999+ warnings.
But the good news is, about 750 of them are being generated from third party frameworks, embedded carthage frameworks, and the like. (For example... we're getting warnings from MagicalRecord, which is included as a Pod... I think it's the shared .h files that are doing it).
We need a way to 'focus' mayday only on our project source files. I'd like to be able to avoid our test directories too, I think.
$ xcodebuild -workspace NSAttributedString+CCLFormat.xcworkspace -scheme Tests test | xcpretty -c
▸ Building Pods/Pods-NSAttributedString+CCLFormat [Debug]
▸ Building Pods/Pods [Debug]
▸ Building NSAttributedString+CCLFormat/Tests [Debug]
▸ Running script 'Check Pods Manifest.lock'
▸ Running script 'Copy Pods Resources'
▸ Running script 'Generate Mayday Flags'
All tests
Test Suite Tests.xctest started
NSAttributedStringTests
✓ testAttributedFormatString (0.007 seconds)
✓ testAttributedFormatStringCanFormatAttributedString (0.000 seconds)
✓ testAttributedFormatStringCanFormatDescription (0.000 seconds)
✓ testAttributedFormatStringCanFormatString (0.000 seconds)
Executed 4 tests, with 0 failures (0 unexpected) in 0.007 (0.009) seconds
Without xcpretty I can see the following:
/Users/kylef/Projects/cocode/NSAttributedString-CCLFormat/Tests/NSAttributedString+CCLFormatTests.m:25: warning: Length of line 124 is longer than 120 characters! [Wmayday]
/Users/kylef/Projects/cocode/NSAttributedString-CCLFormat/Tests/NSAttributedString+CCLFormatTests.m:56: warning: Length of line 147 is longer than 120 characters! [Wmayday]
/Users/kylef/Projects/cocode/NSAttributedString-CCLFormat/Tests/NSAttributedString+CCLFormatTests.m:59: warning: Length of line 145 is longer than 120 characters! [Wmayday]
/Users/kylef/Projects/cocode/NSAttributedString-CCLFormat/Tests/NSAttributedString+CCLFormatTests.m:74: warning: Length of line 126 is longer than 120 characters! [Wmayday]
I did not have colorize installed and ruby complained when I tried to use mayday.
I would like to use mayday as standalone tool, so I am able to run it with an xcode project and set of rules as input parameters and get errors and warning into console. In such case tool could be easily set into continuous delivery pipelines and used without any modifications of projects for non-invasive quality checks of project.
When specifying a match with a custom files: ["glob"]
the specified glob doesn't seem to be included in the script's output. This means that files not ending with *.{m,h,swift}
are not considered.
Here's an example, when trying to specify regex for storyboards:
warning_regex "Misplaced views", /misplaced/, files: ["*.storyboard"]
The (abridged) output looks like this:
def abstract_flag_matcher_9955(file_path, file_contents)
return unless File.fnmatch("*.storyboard", file_path)
return if File.fnmatch("*Pods/*", file_path)
line_number_to_warning_hash = lambda do
lambda do |file_contents|
hash = {}
lines = file_contents.split("
")
lines.each_with_index do |line, line_number|
message = lambda do |line|
line =~ Regexp.new('(?-mix:YES)') ? "Misplaced views" : nil
end
.call(line)
hash[line_number + 1] = message if message
end
hash
end
.call(file_contents)
end.call
if line_number_to_warning_hash && line_number_to_warning_hash.keys.count > 0
final_warning_array = []
line_number_to_warning_hash.map do |line_number, warning_str|
final_warning_array << "#{file_path}:#{line_number}: warning: #{warning_str} [Wmayday]"
end
final_warning_array.join("")
else
false
end
end
Dir[ENV["SRCROOT"] + "/**/*.{m,h,swift}"].each do |filename|
# Could be a dir with .m, like Underscore.m's dir
if (File.file?(filename))
file = File.open(filename, 'r')
file_contents = file.read
abstract_flag_output = abstract_flag_matcher_9955(file.path, file_contents)
if abstract_flag_output && true
puts abstract_flag_output
end
end
end
My understanding here is that:
Dir[ENV["SRCROOT"] + "/**/*.{m,h,swift}"].each do |filename|
Will not include *.storyboard
files, meaning my custom matcher will never get called.
Let me know if I'm totally off here!
If you have a target that depends on another target (such as a test target), mayday
might show warnings/errors twice. A potential fix for this would be, instead of mayday
generating warnings/errors for all source files underneath SRCROOT
, for it to be smarter and first make sure that the source file is a part of the target that owns the build phase.
Would be nice to have mayday init
which is similar to pod init
creating the initial Maydayfile
file along with project and target defined.
Xcode has a third kind of notation, a "note." It shows up in grey (as opposed to yellow or red). It would be great to be able to create note_regex
.
Mayday's tests are failing with xcodeproj 0.20.0
, which it needs to use to avoid having dependency conflicts with cocoapods 0.35.0
.
We love Mayday. Very much hoping you are still maintaining it...
After 6.3 update, Xcode instantly crashes upon running Mayday. Also, no warnings are showing up in the build.
506 zbeckman:Glimpulse$ mayday
Integrating mayday into your project...
Done!
// And... Xcode crashes :-(
Hi,
Do you have another tips using your interesting mayday project ?
Like the number max of a function ?
If a function contain any comments ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.