objective-ci 0.0.1
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.
- data/.gitignore +17 -0
- data/BSD-LICENSE.txt +31 -0
- data/GPL-LICENSE.txt +16 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +92 -0
- data/Rakefile +24 -0
- data/bin/ada_count +4 -0
- data/bin/asm_count +4 -0
- data/bin/awk_count +4 -0
- data/bin/break_filelist +4 -0
- data/bin/c_count +4 -0
- data/bin/cobol_count +4 -0
- data/bin/compute_all +4 -0
- data/bin/compute_sloc_lang +4 -0
- data/bin/count_extensions +4 -0
- data/bin/count_unknown_ext +4 -0
- data/bin/csh_count +4 -0
- data/bin/exp_count +4 -0
- data/bin/f90_count +4 -0
- data/bin/fortran_count +4 -0
- data/bin/generic_count +4 -0
- data/bin/get_sloc +4 -0
- data/bin/get_sloc_details +4 -0
- data/bin/haskell_count +4 -0
- data/bin/java_count +4 -0
- data/bin/jsp_count +4 -0
- data/bin/lex_count +4 -0
- data/bin/lexcount1 +4 -0
- data/bin/lisp_count +4 -0
- data/bin/make_filelists +4 -0
- data/bin/makefile_count +4 -0
- data/bin/ml_count +4 -0
- data/bin/modula3_count +4 -0
- data/bin/objc_count +4 -0
- data/bin/oclint-0.8 +4 -0
- data/bin/oclint-json-compilation-database +4 -0
- data/bin/oclint-xcodebuild +4 -0
- data/bin/pascal_count +4 -0
- data/bin/perl_count +4 -0
- data/bin/php_count +4 -0
- data/bin/pmd-cpd-objc +7 -0
- data/bin/print_sum +4 -0
- data/bin/python_count +4 -0
- data/bin/ruby_count +4 -0
- data/bin/sed_count +4 -0
- data/bin/sh_count +4 -0
- data/bin/show_filecount +4 -0
- data/bin/sloccount +4 -0
- data/bin/sql_count +4 -0
- data/bin/tcl_count +4 -0
- data/docs/jenkins-setup-violations.png +0 -0
- data/docs/jenkins-setup.jpg +0 -0
- data/externals/oclint/oclint-0.8 +0 -0
- data/externals/oclint/oclint-json-compilation-database +86 -0
- data/externals/oclint/oclint-xcodebuild +216 -0
- data/externals/pmd-cpd/ObjCLanguage-0.0.7-SNAPSHOT.jar +0 -0
- data/externals/pmd-cpd/pmd-4.2.5.jar +0 -0
- data/externals/sloccount/ada_count +27 -0
- data/externals/sloccount/asm_count +166 -0
- data/externals/sloccount/awk_count +27 -0
- data/externals/sloccount/break_filelist +1308 -0
- data/externals/sloccount/c_count +0 -0
- data/externals/sloccount/cobol_count +82 -0
- data/externals/sloccount/compute_all +87 -0
- data/externals/sloccount/compute_sloc_lang +66 -0
- data/externals/sloccount/count_extensions +56 -0
- data/externals/sloccount/count_unknown_ext +32 -0
- data/externals/sloccount/csh_count +27 -0
- data/externals/sloccount/exp_count +27 -0
- data/externals/sloccount/f90_count +81 -0
- data/externals/sloccount/fortran_count +83 -0
- data/externals/sloccount/generic_count +77 -0
- data/externals/sloccount/get_sloc +544 -0
- data/externals/sloccount/get_sloc_details +103 -0
- data/externals/sloccount/haskell_count +122 -0
- data/externals/sloccount/java_count +0 -0
- data/externals/sloccount/jsp_count +0 -0
- data/externals/sloccount/lex_count +70 -0
- data/externals/sloccount/lexcount1 +0 -0
- data/externals/sloccount/lisp_count +27 -0
- data/externals/sloccount/make_filelists +193 -0
- data/externals/sloccount/makefile_count +27 -0
- data/externals/sloccount/ml_count +0 -0
- data/externals/sloccount/modula3_count +65 -0
- data/externals/sloccount/objc_count +89 -0
- data/externals/sloccount/pascal_count +0 -0
- data/externals/sloccount/perl_count +147 -0
- data/externals/sloccount/php_count +0 -0
- data/externals/sloccount/print_sum +40 -0
- data/externals/sloccount/python_count +120 -0
- data/externals/sloccount/ruby_count +27 -0
- data/externals/sloccount/sed_count +27 -0
- data/externals/sloccount/sh_count +27 -0
- data/externals/sloccount/show_filecount +58 -0
- data/externals/sloccount/sloccount +258 -0
- data/externals/sloccount/sql_count +76 -0
- data/externals/sloccount/tcl_count +27 -0
- data/lib/objective-ci.rb +3 -0
- data/lib/objective_ci/ci_tasks.rb +142 -0
- data/lib/objective_ci/version.rb +3 -0
- data/objective-ci.gemspec +26 -0
- metadata +255 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
# This is the front-end program "sloccount", part of the
|
|
4
|
+
# SLOCCount tool suite by David A. Wheeler.
|
|
5
|
+
# Given a list of directories, compute the SLOC count,
|
|
6
|
+
# automatically creating the directory $HOME/.slocdata.
|
|
7
|
+
|
|
8
|
+
# This is part of SLOCCount, a toolsuite that counts
|
|
9
|
+
# source lines of code (SLOC).
|
|
10
|
+
# Copyright (C) 2001-2004 David A. Wheeler.
|
|
11
|
+
#
|
|
12
|
+
# This program is free software; you can redistribute it and/or modify
|
|
13
|
+
# it under the terms of the GNU General Public License as published by
|
|
14
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
15
|
+
# (at your option) any later version.
|
|
16
|
+
#
|
|
17
|
+
# This program is distributed in the hope that it will be useful,
|
|
18
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20
|
+
# GNU General Public License for more details.
|
|
21
|
+
#
|
|
22
|
+
# You should have received a copy of the GNU General Public License
|
|
23
|
+
# along with this program; if not, write to the Free Software
|
|
24
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
25
|
+
#
|
|
26
|
+
# To contact David A. Wheeler, see his website at:
|
|
27
|
+
# http://www.dwheeler.com.
|
|
28
|
+
|
|
29
|
+
# See the SLOCCount documentation if you need
|
|
30
|
+
# more details about the license.
|
|
31
|
+
|
|
32
|
+
version=2.26
|
|
33
|
+
|
|
34
|
+
if [ "$#" -eq 0 ]
|
|
35
|
+
then
|
|
36
|
+
echo "Error: You must provide a directory or directories of source code."
|
|
37
|
+
exit 1
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
startingdir=`pwd`
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
# "datadir" is some suitable safe place for the data; here's the default:
|
|
44
|
+
datadir=${HOME}/.slocdata
|
|
45
|
+
|
|
46
|
+
details="n"
|
|
47
|
+
cached="n"
|
|
48
|
+
append="n" # If "append", then don't delete datadir, just add to it.
|
|
49
|
+
oneprogram="--oneprogram"
|
|
50
|
+
display_results="n"
|
|
51
|
+
duplicate_control=""
|
|
52
|
+
autogen=""
|
|
53
|
+
filecount=""
|
|
54
|
+
wide=""
|
|
55
|
+
effort_model=""
|
|
56
|
+
personcost=""
|
|
57
|
+
overhead=""
|
|
58
|
+
follow=""
|
|
59
|
+
addlang=""
|
|
60
|
+
notopfollow=""
|
|
61
|
+
showother=""
|
|
62
|
+
|
|
63
|
+
# Perl 5.8.0 handles the "LANG" environment variable oddly;
|
|
64
|
+
# if it includes ".UTF-8" (which is does in Red Hat Linux 9 and others)
|
|
65
|
+
# then it will bitterly complain about ordinary text.
|
|
66
|
+
# So, we'll need to filter ".UTF-8" out of LANG.
|
|
67
|
+
if [ x"$LANG" != x ]
|
|
68
|
+
then
|
|
69
|
+
LANG=`echo "$LANG" | sed -e 's/\.UTF-8//'`
|
|
70
|
+
export LANG
|
|
71
|
+
# echo "New LANG variable: $LANG"
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
while [ "$#" -gt 0 ]
|
|
75
|
+
do
|
|
76
|
+
case "$1"
|
|
77
|
+
in
|
|
78
|
+
--version) echo "$version"
|
|
79
|
+
exit 0;;
|
|
80
|
+
--cached) cached="y"
|
|
81
|
+
shift;;
|
|
82
|
+
--append) append="y"
|
|
83
|
+
shift;;
|
|
84
|
+
--follow) follow="--follow"
|
|
85
|
+
shift;;
|
|
86
|
+
--notopfollow) notopfollow="--notopfollow"
|
|
87
|
+
shift;;
|
|
88
|
+
--datadir) shift
|
|
89
|
+
if [ ! -d "$1" ]
|
|
90
|
+
then
|
|
91
|
+
echo "Error: $1 is not a directory"
|
|
92
|
+
exit 1
|
|
93
|
+
fi
|
|
94
|
+
cd "$1"
|
|
95
|
+
datadir=`pwd`
|
|
96
|
+
cd $startingdir
|
|
97
|
+
shift;;
|
|
98
|
+
--duplicates) duplicate_control="$1"
|
|
99
|
+
shift;;
|
|
100
|
+
--crossdups) duplicate_control="$1"
|
|
101
|
+
shift;;
|
|
102
|
+
--autogen) autogen="$1"
|
|
103
|
+
shift;;
|
|
104
|
+
--multiproject) oneprogram=""
|
|
105
|
+
shift;;
|
|
106
|
+
--filecount) filecount="$1"
|
|
107
|
+
shift;;
|
|
108
|
+
--filecounts) filecount="$1"
|
|
109
|
+
shift;;
|
|
110
|
+
--wide) wide="$1"
|
|
111
|
+
shift;;
|
|
112
|
+
--details) details="y"
|
|
113
|
+
shift;;
|
|
114
|
+
--addlang) addlang="$addlang $1 $2"
|
|
115
|
+
shift; shift;;
|
|
116
|
+
--addlangall) addlang="--addlangall"
|
|
117
|
+
shift;;
|
|
118
|
+
--showother) showother="--showother"
|
|
119
|
+
shift;;
|
|
120
|
+
--effort) effort_model="$1 $2 $3"
|
|
121
|
+
shift; shift; shift;;
|
|
122
|
+
--schedule) schedule_model="$1 $2 $3"
|
|
123
|
+
shift; shift; shift;;
|
|
124
|
+
--personcost) personcost="$1 $2"
|
|
125
|
+
shift; shift;;
|
|
126
|
+
--overhead) overhead="$1 $2"
|
|
127
|
+
shift; shift;;
|
|
128
|
+
--) break;;
|
|
129
|
+
--*) echo "Error: no such option $1"
|
|
130
|
+
exit 1;;
|
|
131
|
+
*) break;;
|
|
132
|
+
esac
|
|
133
|
+
done
|
|
134
|
+
|
|
135
|
+
# --duplicates) duplicate_control="$1"
|
|
136
|
+
# --autogen) autogen="$1"
|
|
137
|
+
# $follow
|
|
138
|
+
|
|
139
|
+
case "$cached"
|
|
140
|
+
in
|
|
141
|
+
y)
|
|
142
|
+
if [ -n "$duplicate_control" -o -n "$autogen" -o -n "$follow" ]
|
|
143
|
+
then
|
|
144
|
+
echo "Warning: You cannot control what files are selected in a cache."
|
|
145
|
+
echo "The option '--cached' disables --duplicates, --crossdups,"
|
|
146
|
+
echo "--autogen, and --follow. Remove the --cached option if you"
|
|
147
|
+
echo "are changing what you wish to include in your calculations."
|
|
148
|
+
echo
|
|
149
|
+
fi
|
|
150
|
+
if [ -d "$datadir" ]
|
|
151
|
+
then
|
|
152
|
+
display_results="y"
|
|
153
|
+
else
|
|
154
|
+
echo "Sorry, data directory $datadir does not exist."
|
|
155
|
+
exit 1
|
|
156
|
+
fi;;
|
|
157
|
+
n) # Not cached -- need to compute the results.
|
|
158
|
+
|
|
159
|
+
if [ "$append" = "n" ]; then
|
|
160
|
+
if [ -r "${datadir}/sloc_noerase" ]; then
|
|
161
|
+
echo "ERROR! This data directory is marked as do-not-erase."
|
|
162
|
+
echo "Remove the file ${datadir}/sloc_noerase to erase it."
|
|
163
|
+
exit 1
|
|
164
|
+
fi
|
|
165
|
+
if [ "$#" -eq 0 ]; then
|
|
166
|
+
echo "ERROR! No directories for initial analysis supplied."
|
|
167
|
+
exit 1
|
|
168
|
+
fi
|
|
169
|
+
rm -fr "$datadir"
|
|
170
|
+
mkdir "$datadir"
|
|
171
|
+
fi
|
|
172
|
+
|
|
173
|
+
# Now that "datadir" exists, first test to make sure wc -l works.
|
|
174
|
+
wctestfile=${datadir}/.wctestfile
|
|
175
|
+
echo "" > $wctestfile
|
|
176
|
+
echo "line two" >> $wctestfile
|
|
177
|
+
echo "line three" >> $wctestfile
|
|
178
|
+
echo "line four" >> $wctestfile
|
|
179
|
+
testcount=`wc -l < ${wctestfile} | sed -e 's/ //g'`
|
|
180
|
+
if [ "$testcount" -ne 4 ]
|
|
181
|
+
then
|
|
182
|
+
echo "FAILURE! Your wc program's -l option produces wrong results."
|
|
183
|
+
echo "Update your wc (probably in a textutils package) to a correct version."
|
|
184
|
+
exit 1
|
|
185
|
+
fi
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
# Split things up if we're given only one directory on the argument line
|
|
189
|
+
# and that directory has more than one subdirectory:
|
|
190
|
+
split_things_up="n"
|
|
191
|
+
if [ "$#" -eq 1 ]
|
|
192
|
+
then
|
|
193
|
+
count=0
|
|
194
|
+
for x in $1/*
|
|
195
|
+
do
|
|
196
|
+
if [ -d "$x" ]
|
|
197
|
+
then
|
|
198
|
+
count=`expr $count + 1`
|
|
199
|
+
if [ $count -gt 1 ]
|
|
200
|
+
then
|
|
201
|
+
split_things_up="y"
|
|
202
|
+
break
|
|
203
|
+
fi
|
|
204
|
+
fi
|
|
205
|
+
done
|
|
206
|
+
fi
|
|
207
|
+
# If we're appending, don't split things up.
|
|
208
|
+
if [ "$append" = "y" ]
|
|
209
|
+
then
|
|
210
|
+
split_things_up="n"
|
|
211
|
+
fi
|
|
212
|
+
|
|
213
|
+
case $split_things_up
|
|
214
|
+
in
|
|
215
|
+
y) make_filelists $follow $notopfollow --datadir "$datadir" --skip src "$1"/* ||
|
|
216
|
+
exit 1
|
|
217
|
+
if [ -d "$1"/src ]
|
|
218
|
+
then
|
|
219
|
+
make_filelists $notopfollow --datadir "$datadir" --prefix "src_" "$1"/src/* ||
|
|
220
|
+
exit 1
|
|
221
|
+
fi
|
|
222
|
+
;;
|
|
223
|
+
*) make_filelists $follow $notopfollow --datadir "$datadir" "$@" || exit 1
|
|
224
|
+
;;
|
|
225
|
+
esac
|
|
226
|
+
|
|
227
|
+
cd $datadir
|
|
228
|
+
if echo "Categorizing files." &&
|
|
229
|
+
break_filelist --duplistfile sloc_hashes $duplicate_control $autogen * &&
|
|
230
|
+
echo "Computing results." &&
|
|
231
|
+
compute_all *
|
|
232
|
+
then
|
|
233
|
+
display_results=y
|
|
234
|
+
fi
|
|
235
|
+
echo
|
|
236
|
+
echo
|
|
237
|
+
;;
|
|
238
|
+
esac
|
|
239
|
+
|
|
240
|
+
# If we're appending, don't display results.
|
|
241
|
+
if [ "$append" = "y" ]
|
|
242
|
+
then
|
|
243
|
+
display_results="n"
|
|
244
|
+
echo "To display results, use the --cached option."
|
|
245
|
+
fi
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
case $display_results
|
|
249
|
+
in
|
|
250
|
+
y)
|
|
251
|
+
cd $datadir
|
|
252
|
+
case $details
|
|
253
|
+
in
|
|
254
|
+
y) get_sloc_details * ;;
|
|
255
|
+
*) get_sloc $addlang $showother $filecount $oneprogram $effort_model $schedule_model $personcost $overhead * ;;
|
|
256
|
+
esac;;
|
|
257
|
+
esac
|
|
258
|
+
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/perl
|
|
2
|
+
# sql_count - count physical lines of code in SQL.
|
|
3
|
+
|
|
4
|
+
# SQL is really screwed up in its commenting system.
|
|
5
|
+
# In ANSI, "--" means start of comment, but this causes many problems
|
|
6
|
+
# with automatically generated SQL queries. For example, given:
|
|
7
|
+
# UPDATE tbl_name SET credit=credit-!payment!
|
|
8
|
+
# If !payment! is automatically substituted for a negative number,
|
|
9
|
+
# a comment is unexpectedly generated.
|
|
10
|
+
|
|
11
|
+
# So, this program accepts "-- " (dash-dash-space) as a comment character.
|
|
12
|
+
# It also supports "#" and /* .. */, which are supported by MySQL.
|
|
13
|
+
|
|
14
|
+
# This is part of SLOCCount, a toolsuite that counts
|
|
15
|
+
# source lines of code (SLOC).
|
|
16
|
+
# Copyright (C) 2001-2004 David A. Wheeler.
|
|
17
|
+
#
|
|
18
|
+
# This program is free software; you can redistribute it and/or modify
|
|
19
|
+
# it under the terms of the GNU General Public License as published by
|
|
20
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
21
|
+
# (at your option) any later version.
|
|
22
|
+
#
|
|
23
|
+
# This program is distributed in the hope that it will be useful,
|
|
24
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
25
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
26
|
+
# GNU General Public License for more details.
|
|
27
|
+
#
|
|
28
|
+
# You should have received a copy of the GNU General Public License
|
|
29
|
+
# along with this program; if not, write to the Free Software
|
|
30
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
31
|
+
#
|
|
32
|
+
# To contact David A. Wheeler, see his website at:
|
|
33
|
+
# http://www.dwheeler.com.
|
|
34
|
+
#
|
|
35
|
+
#
|
|
36
|
+
|
|
37
|
+
$total_sloc = 0;
|
|
38
|
+
|
|
39
|
+
# Do we have "-f" (read list of files from second argument)?
|
|
40
|
+
if (($#ARGV >= 1) && ($ARGV[0] eq "-f")) {
|
|
41
|
+
# Yes, we have -f
|
|
42
|
+
if ($ARGV[1] eq "-") {
|
|
43
|
+
# The list of files is in STDIN
|
|
44
|
+
while (<STDIN>) {
|
|
45
|
+
chomp ($_);
|
|
46
|
+
&count_file ($_);
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
# The list of files is in the file $ARGV[1]
|
|
50
|
+
open (FILEWITHLIST, $ARGV[1]) || die "Error: Could not open $filewithlist\n";
|
|
51
|
+
while (<FILEWITHLIST>) {
|
|
52
|
+
chomp ($_);
|
|
53
|
+
&count_file ($_);
|
|
54
|
+
}
|
|
55
|
+
close FILEWITHLIST;
|
|
56
|
+
}
|
|
57
|
+
shift @ARGV; shift @ARGV;
|
|
58
|
+
}
|
|
59
|
+
# Process all (remaining) arguments as file names
|
|
60
|
+
while ($file = shift @ARGV) {
|
|
61
|
+
&count_file ($file);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
print "Total:\n";
|
|
65
|
+
print "$total_sloc\n";
|
|
66
|
+
|
|
67
|
+
sub count_file {
|
|
68
|
+
my ($file) = @_;
|
|
69
|
+
my $sloc = 0;
|
|
70
|
+
|
|
71
|
+
$result = `sed -e "s/#.*//" -e "s/-- .*//" < "$file" | c_count`;
|
|
72
|
+
$result =~ m/^\s*([0-9]+)/;
|
|
73
|
+
$sloc = $1;
|
|
74
|
+
print "$sloc $file\n";
|
|
75
|
+
$total_sloc += $sloc;
|
|
76
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
#
|
|
3
|
+
# This is part of SLOCCount, a toolsuite that counts
|
|
4
|
+
# source lines of code (SLOC).
|
|
5
|
+
# Copyright (C) 2001-2004 David A. Wheeler.
|
|
6
|
+
#
|
|
7
|
+
# This program is free software; you can redistribute it and/or modify
|
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
|
9
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
10
|
+
# (at your option) any later version.
|
|
11
|
+
#
|
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
# GNU General Public License for more details.
|
|
16
|
+
#
|
|
17
|
+
# You should have received a copy of the GNU General Public License
|
|
18
|
+
# along with this program; if not, write to the Free Software
|
|
19
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
20
|
+
#
|
|
21
|
+
# To contact David A. Wheeler, see his website at:
|
|
22
|
+
# http://www.dwheeler.com.
|
|
23
|
+
#
|
|
24
|
+
#
|
|
25
|
+
|
|
26
|
+
generic_count '#' $@
|
|
27
|
+
|
data/lib/objective-ci.rb
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
require 'bundler/setup'
|
|
2
|
+
require 'nokogiri'
|
|
3
|
+
|
|
4
|
+
module ObjectiveCi
|
|
5
|
+
class CiTasks
|
|
6
|
+
|
|
7
|
+
attr_accessor :exclusions
|
|
8
|
+
|
|
9
|
+
LINT_DESTINATION = "lint.xml"
|
|
10
|
+
DUPLICATION_DESTINATION = "duplication.xml"
|
|
11
|
+
LINE_COUNT_DESTINATION = "line-count.sc"
|
|
12
|
+
|
|
13
|
+
def initialize
|
|
14
|
+
@exclusions = ["vendor"]
|
|
15
|
+
if using_pods?
|
|
16
|
+
@exclusions << "Pods"
|
|
17
|
+
`bundle exec pod install`
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def build(opts={})
|
|
22
|
+
lint(opts)
|
|
23
|
+
lines_of_code(opts)
|
|
24
|
+
test_suite(opts)
|
|
25
|
+
duplicate_code_detection(opts)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def lint(opts={})
|
|
29
|
+
requires_at_least_one_option(opts, :workspace, :project)
|
|
30
|
+
requires_options(opts, :scheme)
|
|
31
|
+
opts[:configuration] ||= "Release"
|
|
32
|
+
|
|
33
|
+
sliced_opts = opts.select { |k, v| [:scheme, :workspace, :project, :configuration].include?(k) }
|
|
34
|
+
xcodebuild_opts_string = sliced_opts.reduce("") { |str, (k, v)| str += " -#{k} #{v}" }
|
|
35
|
+
xcodebuild_opts_string += " ONLY_ACTIVE_ARCH=NO clean build"
|
|
36
|
+
|
|
37
|
+
call_binary("xcodebuild", xcodebuild_opts_string, "| tee xcodebuild.log", opts)
|
|
38
|
+
# oclint-xcodebuild will fail if we don't exclude Pods (absolute path)
|
|
39
|
+
pods_dir = "#{Dir.pwd}/Pods"
|
|
40
|
+
call_binary("oclint-xcodebuild", "-e \"#{pods_dir}\"", "", opts)
|
|
41
|
+
ocjcd_opts_string = "#{exclusion_options_list("-e")} -- -report-type=pmd -o=#{LINT_DESTINATION}"
|
|
42
|
+
call_binary("oclint-json-compilation-database", ocjcd_opts_string, "", opts)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_suite(opts={})
|
|
46
|
+
requires_at_least_one_option(opts, :workspace, :project)
|
|
47
|
+
requires_options(opts ,:scheme)
|
|
48
|
+
if !opts[:xcodebuild_override] && xcode_version < 5.0
|
|
49
|
+
puts_red "WARNING: Xcode version #{xcode_version} is less than 5.0, and tests will likely not run"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
sliced_opts = opts.select { |k, v| [:scheme, :workspace, :project].include?(k) }
|
|
53
|
+
xcodebuild_opts_string = sliced_opts.reduce("") { |str, (k, v)| str += " -#{k} #{v}" }
|
|
54
|
+
|
|
55
|
+
xcodebuild_opts_string += " -destination name=iPad -destination-timeout=10 ONLY_ACTIVE_ARCH=NO test"
|
|
56
|
+
call_binary("xcodebuild", xcodebuild_opts_string, ">&1 | bundle exec ocunit2junit", opts)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def lines_of_code(opts={})
|
|
60
|
+
call_binary("sloccount",
|
|
61
|
+
"--duplicates --wide --details .",
|
|
62
|
+
"| grep -v #{exclusion_options_list("-e")} > #{LINE_COUNT_DESTINATION}",
|
|
63
|
+
opts)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def duplicate_code_detection(opts={})
|
|
67
|
+
opts[:minimum_tokens] ||= 100
|
|
68
|
+
# Use `sed` to change paths like `/some/code/./path.m` to `/some/code/path.m`, or else the Violations plugin in Jenkins
|
|
69
|
+
# doesn't work correctly.
|
|
70
|
+
call_binary("pmd-cpd-objc",
|
|
71
|
+
"--minimum-tokens #{opts[:minimum_tokens]}",
|
|
72
|
+
"| LC_CTYPE=C LANG=C sed 's/\\/\\.\\//\\//' > #{DUPLICATION_DESTINATION}",
|
|
73
|
+
opts)
|
|
74
|
+
pmd_exclude
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
private
|
|
78
|
+
def exclusion_options_list(option_flag)
|
|
79
|
+
if exclusions.empty?
|
|
80
|
+
''
|
|
81
|
+
else
|
|
82
|
+
wrapped_exclusions = exclusions.map { |e| "\"#{e}\"" }
|
|
83
|
+
"#{option_flag} #{wrapped_exclusions.join(" #{option_flag} ")}"
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
private
|
|
88
|
+
def using_pods?
|
|
89
|
+
File.exists?("Podfile")
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
private
|
|
93
|
+
def call_binary(binary, cl_options, tail, opts={})
|
|
94
|
+
extra_options = opts["#{binary}_options".to_sym]
|
|
95
|
+
override_options = opts["#{binary}_override".to_sym]
|
|
96
|
+
cl_options = override_options ? extra_options : "#{cl_options} #{extra_options}"
|
|
97
|
+
command = "#{binary} #{cl_options} #{tail}"
|
|
98
|
+
command.prepend("bundle exec ") unless binary == "xcodebuild"
|
|
99
|
+
puts command
|
|
100
|
+
`#{command}`
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
private
|
|
104
|
+
def requires_options(opts, *keys)
|
|
105
|
+
keys.each do |k|
|
|
106
|
+
raise "option #{k} is required." unless opts.has_key?(k)
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
private
|
|
111
|
+
def requires_at_least_one_option(opts, *keys)
|
|
112
|
+
if (opts.keys && keys).empty?
|
|
113
|
+
raise "at least one of the options #{keys.join(", ")} is required"
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
private
|
|
118
|
+
def pmd_exclude
|
|
119
|
+
# Unfortunately, pmd doesn't seem to provide any nice out-of-the-box way for excluding files from the results.
|
|
120
|
+
absolute_exclusions = exclusions.map { |e| "#{Dir.pwd}/#{e}/" }
|
|
121
|
+
regex_exclusion = Regexp.new("(#{absolute_exclusions.join("|")})")
|
|
122
|
+
output = Nokogiri::XML(File.open(DUPLICATION_DESTINATION))
|
|
123
|
+
output.xpath("//duplication").each do |duplication_node|
|
|
124
|
+
if duplication_node.xpath("file").all? { |n| n["path"] =~ regex_exclusion }
|
|
125
|
+
duplication_node.remove
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
File.open(DUPLICATION_DESTINATION, 'w') { |file| file.write(output.to_s) }
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
private
|
|
132
|
+
def xcode_version
|
|
133
|
+
matches = `xcodebuild -version`.match(/^Xcode ([0-9]+\.[0-9]+)/)
|
|
134
|
+
matches ? matches[1].to_f : 0.0
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
private
|
|
138
|
+
def puts_red(str)
|
|
139
|
+
puts "\e[31m#{str}\e[0m"
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'objective_ci/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "objective-ci"
|
|
8
|
+
spec.version = ObjectiveCi::VERSION
|
|
9
|
+
spec.authors = ["Mark Larsen"]
|
|
10
|
+
spec.email = ["mark.larsen@sportngin.com"]
|
|
11
|
+
spec.description = %q{CI tools for objective-c}
|
|
12
|
+
spec.summary = %q{CI tools for objective-c}
|
|
13
|
+
spec.homepage = ""
|
|
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_development_dependency "bundler", "~> 1.3"
|
|
22
|
+
spec.add_development_dependency "rake"
|
|
23
|
+
|
|
24
|
+
spec.add_dependency "ocunit2junit"
|
|
25
|
+
spec.add_dependency "nokogiri"
|
|
26
|
+
end
|