Skip to content

Commit

Permalink
use Travis to look for spelling errors
Browse files Browse the repository at this point in the history
use silver searcher for faster search (instead of grep)
  • Loading branch information
3nids committed Dec 15, 2016
1 parent 417a5cd commit 90fc0bb
Show file tree
Hide file tree
Showing 11 changed files with 163 additions and 55 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Expand Up @@ -22,6 +22,7 @@ matrix:
- llvm-toolchain-precise-3.8
- ubuntu-toolchain-r-test
- george-edison55-precise-backports # doxygen 1.8.3
# - laurent-boulard-devtools not whitelisted yet https://github.com/travis-ci/apt-source-whitelist/pull/345
packages:
- doxygen
- bison
Expand All @@ -36,11 +37,15 @@ matrix:
- xvfb
- flip
- clang-3.8
# used for spell checks
# - silversearcher-ag not available in precise nor in a white listed ppa (in osgeo4travis as for now)
- expect-dev # unbuffer
# OSX based build with QT4 and Python 2
# - os: osx
# env:
# - BUILD=osx
# - IGNORE_BUILD_FAILURES=YES


git:
depth: 30
Expand Down Expand Up @@ -70,6 +75,7 @@ before_script:

script:
- ./ci/travis/${TRAVIS_OS_NAME}/script.sh
- ./ci/travis/check_spelling.sh

after_script:
- ./ci/travis/${TRAVIS_OS_NAME}/after_script.sh
17 changes: 17 additions & 0 deletions ci/travis/check_spelling.sh
@@ -0,0 +1,17 @@
#!/bin/bash
set -e

export PATH=${HOME}/osgeo4travis/bin:${PATH}


echo "Spell check"

if [[ ! -z $TRAVIS_PULL_REQUEST_BRANCH ]]; then
# if on a PR, just analyse the changed files
echo "TRAVIS PR BRANCH: $TRAVIS_PULL_REQUEST_BRANCH"
FILES=$(git diff --name-only HEAD $(git merge-base HEAD master) | tr '\n' ' ' )
fi


CODE=$(./scripts/chkspelling_ag.sh)
exit $CODE
4 changes: 2 additions & 2 deletions python/core/qgstaskmanager.sip
Expand Up @@ -117,7 +117,7 @@ class QgsTask : QObject
* Subtasks allow a single task to be created which
* consists of multiple smaller tasks. Subtasks are not visible or indepedently
* controllable by users. Ownership of the subtask is transferred.
* Subtasks can have an optional list of dependant tasks, which must be completed
* Subtasks can have an optional list of dependent tasks, which must be completed
* before the subtask can begin. By default subtasks are considered independent
* of the parent task, ie they can be run either before, after, or at the same
* time as the parent task. This behaviour can be overriden through the subTaskDependency
Expand Down Expand Up @@ -286,7 +286,7 @@ class QgsTaskManager : QObject
long addTask( QgsTask* task /Transfer/, int priority = 0 );

/**
* Adds a task to the manager, using a full task definition (including dependancy
* Adds a task to the manager, using a full task definition (including dependency
* handling). Ownership of the task is transferred to the manager, and the task
* manager will be responsible for starting the task. The priority argument can
* be used to control the run queue's order of execution.
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/help/qgis.yaml
Expand Up @@ -90,7 +90,7 @@ qgis:countuniquepointsinpolygon: >
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.

qgis:createattributeindex: >
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.
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.

qgis:createconstantrasterlayer: >
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.
Expand Down
38 changes: 38 additions & 0 deletions scripts/.agignore
@@ -0,0 +1,38 @@
# Folders
.build*/
ci/
debian/build.*/
debian/build*/
debian/.*/usr/
i18n/
ms-windows/osgeo4w/
python/ext-libs/
python/plugins/processing/algs/otb/
python/plugins/processing/algs/saga/
python/qsci_apis/
src/app/dwg/libdxfrw/
src/app/gps/qwtpolar-1.0/
src/app/gps/qwtpolar-1.1.1/
src/plugins/grass/qtermwidget/

#Extensions
*.*.orig
*.*.sortinc
*.*.prepare


#Specific files
ChangeLog
Exception_to_GPL_for_Qt.txt
images/themes/default/svgbase/hammer.svg
images/themes/default/propertyicons/general.svg
LexerR.py
spelling.dat
resources/cpt-city-qgis-min/fme/metres/DESC.xml
resources/cpt-city-qgis-min/wkp/schwarzwald/COPYING.xml
tests/src/python/test_qgsserver_accesscontrol.py
tests/testdata/qgis_server/ets-wms13/project.qgs
tests/testdata/qgis_server_accesscontrol/project.qgs
tests/testdata/qgis_server_accesscontrol/Hello.qml


39 changes: 39 additions & 0 deletions scripts/chkspelling_ag.sh
@@ -0,0 +1,39 @@
#!/bin/bash
###########################################################################
# chkspelling.sh
# ---------------------
# Date : December 2016
# Copyright : (C) 2016 by Denis Rouzaud
# Email : denis.rouzaud@gmail.com
###########################################################################
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License, or #
# (at your option) any later version. #
# #
###########################################################################

# optional arguments: files to be checked


RE=$(cut -d: -f1 scripts/spelling.dat | tr '\n' '\|' | sed -e 's/|$//')
if [ ! $# -eq 0 ]; then
EXCLUDE=$(cat ci/travis/.agignore | sed -e 's/\s*#.*$//' -e '/^\s*$/d' | tr '\n' '|' | sed -e 's/|$//')
FILES=$(echo $@ | tr -s '[[:blank:]]' '\n' | egrep -iv "$EXCLUDE" | tr '\n' ' ' )
echo "Running spell check on files: $FILES"
else
FILES="."
fi


exec 5>&1
OUTPUT=$(ag --smart-case --all-text --nopager --numbers --word-regexp --path-to-ignore scripts/.agignore "$RE" $FILES |tee /dev/fd/5)


if [[ ! -z $OUTPUT ]]; then
echo "Spelling errors have been found"
exit 1
else
exit 0
fi
90 changes: 48 additions & 42 deletions scripts/prepare-commit.sh
Expand Up @@ -21,30 +21,36 @@ PATH=$TOPLEVEL/scripts:$PATH
cd $TOPLEVEL

if ! type -p astyle.sh >/dev/null; then
echo astyle.sh not found
exit 1
echo astyle.sh not found
exit 1
fi

if ! type -p colordiff >/dev/null; then
colordiff()
{
cat "$@"
}
colordiff()
{
cat "$@"
}
fi

if [ "$1" = "-c" ]; then
echo "Cleaning..."
remove_temporary_files.sh
echo "Cleaning..."
remove_temporary_files.sh
fi

set -e

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

CODE=$(./$TOPLEVEL/scripts/chkspelling_ag.sh $MODIFIED)
if [ code -eq 1]; then
exit 1
fi


if [ -z "$MODIFIED" ]; then
echo nothing was modified
exit 0
echo nothing was modified
exit 0
fi

# save original changes
Expand All @@ -58,42 +64,42 @@ ASTYLEDIFF=astyle.$REV.diff
i=0
N=$(echo $MODIFIED | wc -w)
for f in $MODIFIED; do
(( i++ )) || true

case "$f" in
src/core/gps/qextserialport/*|src/plugins/globe/osgEarthQt/*|src/plugins/globe/osgEarthUtil/*)
echo $f skipped
continue
;;

*.cpp|*.c|*.h|*.cxx|*.hxx|*.c++|*.h++|*.cc|*.hh|*.C|*.H|*.sip|*.py)
;;

*)
continue
;;
esac

m=$f.$REV.prepare

cp $f $m
ASTYLEPROGRESS=" [$i/$N]" astyle.sh $f
if diff -u $m $f >>$ASTYLEDIFF; then
# no difference found
rm $m
fi
(( i++ )) || true

case "$f" in
src/core/gps/qextserialport/*|src/plugins/globe/osgEarthQt/*|src/plugins/globe/osgEarthUtil/*)
echo $f skipped
continue
;;

*.cpp|*.c|*.h|*.cxx|*.hxx|*.c++|*.h++|*.cc|*.hh|*.C|*.H|*.sip|*.py)
;;

*)
continue
;;
esac

m=$f.$REV.prepare

cp $f $m
ASTYLEPROGRESS=" [$i/$N]" astyle.sh $f
if diff -u $m $f >>$ASTYLEDIFF; then
# no difference found
rm $m
fi
done

if [ -s "$ASTYLEDIFF" ]; then
if tty -s; then
# review astyle changes
colordiff <$ASTYLEDIFF | less -r
else
echo "Files changed (see $ASTYLEDIFF)"
fi
exit 1
if tty -s; then
# review astyle changes
colordiff <$ASTYLEDIFF | less -r
else
echo "Files changed (see $ASTYLEDIFF)"
fi
exit 1
else
rm $ASTYLEDIFF
rm $ASTYLEDIFF
fi

exit 0
Expand Down
2 changes: 2 additions & 0 deletions scripts/spelling.dat
Expand Up @@ -313,6 +313,8 @@ optionnal:optional
optmizations:optimizations
orientatied:orientated
orientied:oriented
orthagonal:orthogonal
orthagonalize:orthogonalize
overaall:overall
overidden:overridden
overide:override
Expand Down
6 changes: 3 additions & 3 deletions src/core/qgstaskmanager.cpp
Expand Up @@ -626,7 +626,7 @@ void QgsTaskManager::taskStatusChanged( int status )

if ( status == QgsTask::Terminated )
{
//recursively cancel dependant tasks
//recursively cancel dependent tasks
cancelDependentTasks( id );
}

Expand Down Expand Up @@ -790,9 +790,9 @@ void QgsTaskManager::cancelDependentTasks( long taskId )
{
if ( it.value().contains( cancelledTask ) )
{
// found task with this dependancy
// found task with this dependency

// cancel it - note that this will be recursive, so any tasks dependant
// cancel it - note that this will be recursive, so any tasks dependent
// on this one will also be cancelled
QgsTask* dependentTask = task( it.key() );
if ( dependentTask )
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgstaskmanager.h
Expand Up @@ -148,7 +148,7 @@ class CORE_EXPORT QgsTask : public QObject
* Subtasks allow a single task to be created which
* consists of multiple smaller tasks. Subtasks are not visible or indepedently
* controllable by users. Ownership of the subtask is transferred.
* Subtasks can have an optional list of dependant tasks, which must be completed
* Subtasks can have an optional list of dependent tasks, which must be completed
* before the subtask can begin. By default subtasks are considered independent
* of the parent task, ie they can be run either before, after, or at the same
* time as the parent task. This behaviour can be overriden through the subTaskDependency
Expand Down Expand Up @@ -381,7 +381,7 @@ class CORE_EXPORT QgsTaskManager : public QObject
long addTask( QgsTask* task, int priority = 0 );

/**
* Adds a task to the manager, using a full task definition (including dependancy
* Adds a task to the manager, using a full task definition (including dependency
* handling). Ownership of the task is transferred to the manager, and the task
* manager will be responsible for starting the task. The priority argument can
* be used to control the run queue's order of execution, with larger numbers
Expand Down
10 changes: 5 additions & 5 deletions tests/src/core/testqgstaskmanager.cpp
Expand Up @@ -202,7 +202,7 @@ class TestQgsTaskManager : public QObject
void allTasksFinished();
void activeTasks();
void holdTask();
void dependancies();
void dependencies();
void layerDependencies();
void managerWithSubTasks();
void managerWithSubTasks2();
Expand Down Expand Up @@ -923,11 +923,11 @@ void TestQgsTaskManager::holdTask()
task->cancel();
}

void TestQgsTaskManager::dependancies()
void TestQgsTaskManager::dependencies()
{
QgsTaskManager manager;

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

// test that tasks are queued until dependancies are resolved
// test that tasks are queued until dependencies are resolved
task = new CancelableTask();
childTask = new CancelableTask();
childTask->hold();
Expand Down Expand Up @@ -1023,7 +1023,7 @@ void TestQgsTaskManager::layerDependencies()

QgsTaskManager manager;

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

0 comments on commit 90fc0bb

Please sign in to comment.