Skip to content

Commit 90fc0bb

Browse files
committed
use Travis to look for spelling errors
use silver searcher for faster search (instead of grep)
1 parent 417a5cd commit 90fc0bb

File tree

11 files changed

+163
-55
lines changed

11 files changed

+163
-55
lines changed

.travis.yml

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ matrix:
2222
- llvm-toolchain-precise-3.8
2323
- ubuntu-toolchain-r-test
2424
- george-edison55-precise-backports # doxygen 1.8.3
25+
# - laurent-boulard-devtools not whitelisted yet https://github.com/travis-ci/apt-source-whitelist/pull/345
2526
packages:
2627
- doxygen
2728
- bison
@@ -36,11 +37,15 @@ matrix:
3637
- xvfb
3738
- flip
3839
- clang-3.8
40+
# used for spell checks
41+
# - silversearcher-ag not available in precise nor in a white listed ppa (in osgeo4travis as for now)
42+
- expect-dev # unbuffer
3943
# OSX based build with QT4 and Python 2
4044
# - os: osx
4145
# env:
4246
# - BUILD=osx
4347
# - IGNORE_BUILD_FAILURES=YES
48+
4449

4550
git:
4651
depth: 30
@@ -70,6 +75,7 @@ before_script:
7075

7176
script:
7277
- ./ci/travis/${TRAVIS_OS_NAME}/script.sh
78+
- ./ci/travis/check_spelling.sh
7379

7480
after_script:
7581
- ./ci/travis/${TRAVIS_OS_NAME}/after_script.sh

ci/travis/check_spelling.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
set -e
3+
4+
export PATH=${HOME}/osgeo4travis/bin:${PATH}
5+
6+
7+
echo "Spell check"
8+
9+
if [[ ! -z $TRAVIS_PULL_REQUEST_BRANCH ]]; then
10+
# if on a PR, just analyse the changed files
11+
echo "TRAVIS PR BRANCH: $TRAVIS_PULL_REQUEST_BRANCH"
12+
FILES=$(git diff --name-only HEAD $(git merge-base HEAD master) | tr '\n' ' ' )
13+
fi
14+
15+
16+
CODE=$(./scripts/chkspelling_ag.sh)
17+
exit $CODE

python/core/qgstaskmanager.sip

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class QgsTask : QObject
117117
* Subtasks allow a single task to be created which
118118
* consists of multiple smaller tasks. Subtasks are not visible or indepedently
119119
* controllable by users. Ownership of the subtask is transferred.
120-
* Subtasks can have an optional list of dependant tasks, which must be completed
120+
* Subtasks can have an optional list of dependent tasks, which must be completed
121121
* before the subtask can begin. By default subtasks are considered independent
122122
* of the parent task, ie they can be run either before, after, or at the same
123123
* time as the parent task. This behaviour can be overriden through the subTaskDependency
@@ -286,7 +286,7 @@ class QgsTaskManager : QObject
286286
long addTask( QgsTask* task /Transfer/, int priority = 0 );
287287

288288
/**
289-
* Adds a task to the manager, using a full task definition (including dependancy
289+
* Adds a task to the manager, using a full task definition (including dependency
290290
* handling). Ownership of the task is transferred to the manager, and the task
291291
* manager will be responsible for starting the task. The priority argument can
292292
* be used to control the run queue's order of execution.

python/plugins/processing/algs/help/qgis.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ qgis:countuniquepointsinpolygon: >
9090
A new polygons layer is generated, with the exact same content as the input polygons layer, but containing an additional field with the points count corresponding to each polygon.
9191

9292
qgis:createattributeindex: >
93-
Creates an index to speed up queries made against a field in a table. Support for index creation is dependant on the layer's data provider and the field type.
93+
Creates an index to speed up queries made against a field in a table. Support for index creation is dependent on the layer's data provider and the field type.
9494

9595
qgis:createconstantrasterlayer: >
9696
Given an input raster layer an a value, this algorithm generates a new layer with the same extent and cellsize as the input one, and all cells with the specified value.

scripts/.agignore

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Folders
2+
.build*/
3+
ci/
4+
debian/build.*/
5+
debian/build*/
6+
debian/.*/usr/
7+
i18n/
8+
ms-windows/osgeo4w/
9+
python/ext-libs/
10+
python/plugins/processing/algs/otb/
11+
python/plugins/processing/algs/saga/
12+
python/qsci_apis/
13+
src/app/dwg/libdxfrw/
14+
src/app/gps/qwtpolar-1.0/
15+
src/app/gps/qwtpolar-1.1.1/
16+
src/plugins/grass/qtermwidget/
17+
18+
#Extensions
19+
*.*.orig
20+
*.*.sortinc
21+
*.*.prepare
22+
23+
24+
#Specific files
25+
ChangeLog
26+
Exception_to_GPL_for_Qt.txt
27+
images/themes/default/svgbase/hammer.svg
28+
images/themes/default/propertyicons/general.svg
29+
LexerR.py
30+
spelling.dat
31+
resources/cpt-city-qgis-min/fme/metres/DESC.xml
32+
resources/cpt-city-qgis-min/wkp/schwarzwald/COPYING.xml
33+
tests/src/python/test_qgsserver_accesscontrol.py
34+
tests/testdata/qgis_server/ets-wms13/project.qgs
35+
tests/testdata/qgis_server_accesscontrol/project.qgs
36+
tests/testdata/qgis_server_accesscontrol/Hello.qml
37+
38+

scripts/chkspelling_ag.sh

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
###########################################################################
3+
# chkspelling.sh
4+
# ---------------------
5+
# Date : December 2016
6+
# Copyright : (C) 2016 by Denis Rouzaud
7+
# Email : denis.rouzaud@gmail.com
8+
###########################################################################
9+
# #
10+
# This program is free software; you can redistribute it and/or modify #
11+
# it under the terms of the GNU General Public License as published by #
12+
# the Free Software Foundation; either version 2 of the License, or #
13+
# (at your option) any later version. #
14+
# #
15+
###########################################################################
16+
17+
# optional arguments: files to be checked
18+
19+
20+
RE=$(cut -d: -f1 scripts/spelling.dat | tr '\n' '\|' | sed -e 's/|$//')
21+
if [ ! $# -eq 0 ]; then
22+
EXCLUDE=$(cat ci/travis/.agignore | sed -e 's/\s*#.*$//' -e '/^\s*$/d' | tr '\n' '|' | sed -e 's/|$//')
23+
FILES=$(echo $@ | tr -s '[[:blank:]]' '\n' | egrep -iv "$EXCLUDE" | tr '\n' ' ' )
24+
echo "Running spell check on files: $FILES"
25+
else
26+
FILES="."
27+
fi
28+
29+
30+
exec 5>&1
31+
OUTPUT=$(ag --smart-case --all-text --nopager --numbers --word-regexp --path-to-ignore scripts/.agignore "$RE" $FILES |tee /dev/fd/5)
32+
33+
34+
if [[ ! -z $OUTPUT ]]; then
35+
echo "Spelling errors have been found"
36+
exit 1
37+
else
38+
exit 0
39+
fi

scripts/prepare-commit.sh

+48-42
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,36 @@ PATH=$TOPLEVEL/scripts:$PATH
2121
cd $TOPLEVEL
2222

2323
if ! type -p astyle.sh >/dev/null; then
24-
echo astyle.sh not found
25-
exit 1
24+
echo astyle.sh not found
25+
exit 1
2626
fi
2727

2828
if ! type -p colordiff >/dev/null; then
29-
colordiff()
30-
{
31-
cat "$@"
32-
}
29+
colordiff()
30+
{
31+
cat "$@"
32+
}
3333
fi
3434

3535
if [ "$1" = "-c" ]; then
36-
echo "Cleaning..."
37-
remove_temporary_files.sh
36+
echo "Cleaning..."
37+
remove_temporary_files.sh
3838
fi
3939

4040
set -e
4141

4242
# determine changed files
4343
MODIFIED=$(git status --porcelain| sed -ne "s/^ *[MA] *//p" | sort -u)
4444

45+
CODE=$(./$TOPLEVEL/scripts/chkspelling_ag.sh $MODIFIED)
46+
if [ code -eq 1]; then
47+
exit 1
48+
fi
49+
50+
4551
if [ -z "$MODIFIED" ]; then
46-
echo nothing was modified
47-
exit 0
52+
echo nothing was modified
53+
exit 0
4854
fi
4955

5056
# save original changes
@@ -58,42 +64,42 @@ ASTYLEDIFF=astyle.$REV.diff
5864
i=0
5965
N=$(echo $MODIFIED | wc -w)
6066
for f in $MODIFIED; do
61-
(( i++ )) || true
62-
63-
case "$f" in
64-
src/core/gps/qextserialport/*|src/plugins/globe/osgEarthQt/*|src/plugins/globe/osgEarthUtil/*)
65-
echo $f skipped
66-
continue
67-
;;
68-
69-
*.cpp|*.c|*.h|*.cxx|*.hxx|*.c++|*.h++|*.cc|*.hh|*.C|*.H|*.sip|*.py)
70-
;;
71-
72-
*)
73-
continue
74-
;;
75-
esac
76-
77-
m=$f.$REV.prepare
78-
79-
cp $f $m
80-
ASTYLEPROGRESS=" [$i/$N]" astyle.sh $f
81-
if diff -u $m $f >>$ASTYLEDIFF; then
82-
# no difference found
83-
rm $m
84-
fi
67+
(( i++ )) || true
68+
69+
case "$f" in
70+
src/core/gps/qextserialport/*|src/plugins/globe/osgEarthQt/*|src/plugins/globe/osgEarthUtil/*)
71+
echo $f skipped
72+
continue
73+
;;
74+
75+
*.cpp|*.c|*.h|*.cxx|*.hxx|*.c++|*.h++|*.cc|*.hh|*.C|*.H|*.sip|*.py)
76+
;;
77+
78+
*)
79+
continue
80+
;;
81+
esac
82+
83+
m=$f.$REV.prepare
84+
85+
cp $f $m
86+
ASTYLEPROGRESS=" [$i/$N]" astyle.sh $f
87+
if diff -u $m $f >>$ASTYLEDIFF; then
88+
# no difference found
89+
rm $m
90+
fi
8591
done
8692

8793
if [ -s "$ASTYLEDIFF" ]; then
88-
if tty -s; then
89-
# review astyle changes
90-
colordiff <$ASTYLEDIFF | less -r
91-
else
92-
echo "Files changed (see $ASTYLEDIFF)"
93-
fi
94-
exit 1
94+
if tty -s; then
95+
# review astyle changes
96+
colordiff <$ASTYLEDIFF | less -r
97+
else
98+
echo "Files changed (see $ASTYLEDIFF)"
99+
fi
100+
exit 1
95101
else
96-
rm $ASTYLEDIFF
102+
rm $ASTYLEDIFF
97103
fi
98104

99105
exit 0

scripts/spelling.dat

+2
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ optionnal:optional
313313
optmizations:optimizations
314314
orientatied:orientated
315315
orientied:oriented
316+
orthagonal:orthogonal
317+
orthagonalize:orthogonalize
316318
overaall:overall
317319
overidden:overridden
318320
overide:override

src/core/qgstaskmanager.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ void QgsTaskManager::taskStatusChanged( int status )
626626

627627
if ( status == QgsTask::Terminated )
628628
{
629-
//recursively cancel dependant tasks
629+
//recursively cancel dependent tasks
630630
cancelDependentTasks( id );
631631
}
632632

@@ -790,9 +790,9 @@ void QgsTaskManager::cancelDependentTasks( long taskId )
790790
{
791791
if ( it.value().contains( cancelledTask ) )
792792
{
793-
// found task with this dependancy
793+
// found task with this dependency
794794

795-
// cancel it - note that this will be recursive, so any tasks dependant
795+
// cancel it - note that this will be recursive, so any tasks dependent
796796
// on this one will also be cancelled
797797
QgsTask* dependentTask = task( it.key() );
798798
if ( dependentTask )

src/core/qgstaskmanager.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class CORE_EXPORT QgsTask : public QObject
148148
* Subtasks allow a single task to be created which
149149
* consists of multiple smaller tasks. Subtasks are not visible or indepedently
150150
* controllable by users. Ownership of the subtask is transferred.
151-
* Subtasks can have an optional list of dependant tasks, which must be completed
151+
* Subtasks can have an optional list of dependent tasks, which must be completed
152152
* before the subtask can begin. By default subtasks are considered independent
153153
* of the parent task, ie they can be run either before, after, or at the same
154154
* time as the parent task. This behaviour can be overriden through the subTaskDependency
@@ -381,7 +381,7 @@ class CORE_EXPORT QgsTaskManager : public QObject
381381
long addTask( QgsTask* task, int priority = 0 );
382382

383383
/**
384-
* Adds a task to the manager, using a full task definition (including dependancy
384+
* Adds a task to the manager, using a full task definition (including dependency
385385
* handling). Ownership of the task is transferred to the manager, and the task
386386
* manager will be responsible for starting the task. The priority argument can
387387
* be used to control the run queue's order of execution, with larger numbers

tests/src/core/testqgstaskmanager.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class TestQgsTaskManager : public QObject
202202
void allTasksFinished();
203203
void activeTasks();
204204
void holdTask();
205-
void dependancies();
205+
void dependencies();
206206
void layerDependencies();
207207
void managerWithSubTasks();
208208
void managerWithSubTasks2();
@@ -923,11 +923,11 @@ void TestQgsTaskManager::holdTask()
923923
task->cancel();
924924
}
925925

926-
void TestQgsTaskManager::dependancies()
926+
void TestQgsTaskManager::dependencies()
927927
{
928928
QgsTaskManager manager;
929929

930-
//test that cancelling tasks cancels all tasks which are dependant on them
930+
//test that cancelling tasks cancels all tasks which are dependent on them
931931
CancelableTask* task = new CancelableTask();
932932
task->hold();
933933
CancelableTask* childTask = new CancelableTask();
@@ -952,7 +952,7 @@ void TestQgsTaskManager::dependancies()
952952
QCOMPARE( childTask->status(), QgsTask::Terminated );
953953
QCOMPARE( task->status(), QgsTask::Terminated );
954954

955-
// test that tasks are queued until dependancies are resolved
955+
// test that tasks are queued until dependencies are resolved
956956
task = new CancelableTask();
957957
childTask = new CancelableTask();
958958
childTask->hold();
@@ -1023,7 +1023,7 @@ void TestQgsTaskManager::layerDependencies()
10231023

10241024
QgsTaskManager manager;
10251025

1026-
//test that remove layers cancels all tasks which are dependant on them
1026+
//test that remove layers cancels all tasks which are dependent on them
10271027
TestTask* task = new TestTask();
10281028
task->hold();
10291029
task->setDependentLayers( QStringList() << layer2->id() << layer3->id() );

0 commit comments

Comments
 (0)