Skip to content

Commit

Permalink
add linter script and fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mzuther committed Jul 16, 2020
1 parent 6c2b92c commit 7c7892b
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 38 deletions.
3 changes: 3 additions & 0 deletions src/ProtoFaust.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ void ProtoFaust::process( const ProcessArgs& args )
FaustDSP.init( args.sampleRate );
}

// cppcheck-suppress allocaCalled ; Stéphane knows what he is doing ...
FAUSTFLOAT* temporaryInputs = ( FAUSTFLOAT* ) alloca( numberOfChannels *
sizeof( FAUSTFLOAT ) );

// cppcheck-suppress allocaCalled
FAUSTFLOAT* temporaryOutputs = ( FAUSTFLOAT* ) alloca( numberOfChannels *
sizeof( FAUSTFLOAT ) );

Expand Down
4 changes: 2 additions & 2 deletions src/ProtoFaustWidget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ struct ProtoFaustWidget : ModuleWidget {
explicit ProtoFaustWidget( ProtoFaust* module );

private:
void addWidget( int parameterId,
int widgetType,
void addWidget( int widgetType,
int parameterId,
float x,
float y );

Expand Down
4 changes: 2 additions & 2 deletions src/WidgetAccess.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ struct WidgetAccess {

WidgetAccess( int widget_type,
int parameter_id,
setFunction set,
getFunction get ) :
setFunction& set,
getFunction& get ) :
widgetType( widget_type ),
parameterId( parameter_id ),
faustSet( set ),
Expand Down
34 changes: 0 additions & 34 deletions src/format_code.bat

This file was deleted.

97 changes: 97 additions & 0 deletions src/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#! /usr/bin/env bash

# ----------------------------------------------------------------------------
#
# ProtoFaust
# ==========
# DSP prototyping in Faust for VCV Rack
#
# Copyright (c) 2019-2020 Martin Zuther (http://www.mzuther.de/) and
# contributors
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Thank you for using free software!
#
# ----------------------------------------------------------------------------


###############################################################################
#
# WARNING: this file is auto-generated, please do not edit!
#
###############################################################################

project_home=$(pwd)/..


function lint_file
{
filename="$1"
dirname=$(dirname "$1")
project_home="$2"

printf "%s\n" "$filename"

clang \
-x c++ - \
-include "$project_home/src/Amalgamated.hpp" \
-I "$project_home/../Rack-SDK/dep/include" \
-I "$project_home/../Rack-SDK/include" \
-I "$dirname" \
-fsyntax-only \
-fno-caret-diagnostics \
-fcolor-diagnostics \
-std=c++14 \
-Wall \
< "$filename"

cppcheck \
--template=gcc \
--enable=style \
--inline-suppr \
--language=c++ \
--force \
--quiet \
"$filename" 2>&1 | \
sed -Ee 's/[^:]+://' | \
GREP_COLORS="mt=01;31" grep --extended-regexp --colour=always \
--label "$filename" --with-filename \
'[^0-9:].*'

# find error-like codetags
GREP_COLORS="mt=01;31" grep --extended-regexp --colour=always \
--with-filename --line-number \
'\<(BUG|FIXME|XXX)\>' \
"$filename"

# find warning-like codetags
GREP_COLORS="mt=01;33" grep --extended-regexp --colour=always \
--with-filename --line-number \
'\<(HACK|TODO|@todo)\>' \
"$filename"
}


export -f lint_file
printf "\n"

find . -maxdepth 1 \( -iname "*.cpp" -or -iname "*.hpp" \) \
! -name "Amalgamated.hpp" \
! -name "faust_generated.cpp" -print | \
sort | \
parallel --will-cite --group \
lint_file {} "$project_home"

printf "\n"

0 comments on commit 7c7892b

Please sign in to comment.