This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def complexity filename | |
| File.read(filename).lines.grep(/^([ \t]*)/) { $1 }.map(&:length).reduce(0, :+) | |
| end | |
| filenames = `git log --name-only | grep \.rb$`.lines \ | |
| .map(&:strip) \ | |
| .reject { |fn| fn.include? "_spec" } \ | |
| .reject { |fn| fn.include? "vendor" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def complexity filename | |
| File.read(filename).lines.grep(/^([ \t]*)/) { $1 }.map(&:length).reduce(0, :+) | |
| end | |
| commit_filenames = `git log --name-only | grep \.rb$`.lines \ | |
| .map(&:strip) \ | |
| .reject { |fn| fn.include? "_spec" } \ | |
| .reject { |fn| fn.include? "vendor" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git log --name-only --no-merges | grep \.rb$ | sort | uniq -c | sort -nr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # A poor man's complexity measure for a file or group of files | |
| puts ARGF.lines.grep(/^([ \t]*)/) { $1 }.map(&:length).reduce(0, :+) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Data.List | |
| lineBreak :: String -> String | |
| lineBreak = joinBrokenLines . joinWordsInBrokenLines . brokenLines . words | |
| brokenLines :: [String] -> [[String]] | |
| brokenLines [] = [] | |
| brokenLines wordList = brokenLine : brokenLines remainingWords | |
| where (brokenLine, remainingWords) = splitAt (brokenLineWordCount wordList) wordList |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* On Array */ | |
| VALUE | |
| rb_ary_each(ary) | |
| VALUE ary; | |
| { | |
| long i; | |
| for (i=0; i<RARRAY(ary)->len; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Object | |
| def method_missing m, *args | |
| Object.respond_to?(m, true) ? Object.send(m, self, *args) : super | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Modeled on the behavior of https://github.com/burkhartt/Tim.SentenceParser/blob/master/Tim.SentenceParser/Tim.SentenceParser/SentenceParser.cs | |
| import Char | |
| withoutLastWord :: String -> String | |
| withoutLastWord = unwords . init . words | |
| sentenceBefore :: String -> Int -> String | |
| sentenceBefore "" _ = "" | |
| sentenceBefore _ 0 = "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # :: [event] -> [month,int] | |
| def avg_lines_per_commit_by_month events | |
| cls_by_month = lines_added_per_commit(events).group_by {|date,_| month_from_date(date) } | |
| cls_by_month.map {|_,cls| cls.map {|cl| cl[1]}.mean }.flatten | |
| end | |
| # :: [event] -> Float | |
| def percent_reduction method_events | |
| non_deleted = method_events.select {|e| e.status != :deleted } | |
| return 0.0 if non_deleted.count == 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def perform | |
| @results ||= {} | |
| puts "Looking up query" | |
| query = Query.find_by_id(options["query_id"]) | |
| engine = Quote::Engine.create(query) | |
| puts "Finding quotes" | |
| quotes = engine.find_quotes(options["options"]) | |
| puts "Found quotes" | |
| # NOTE: | |
| # This is here so that sorting and filtering can take advantage |