update credits
[LibreOffice.git] / bin / find-unused-using.sh
blob5aa6e34abcb603c1f8c37b1eeedff5947d99ff83
1 # This file is part of the LibreOffice project.
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 #!/bin/bash
8 for ns in accessibility basegfx chart com css cppu comphelper connectivity formula dbtools editeng rtl sfx2 svt osl oox sax_fastparser sal sd ucbhelper utl vcl xmloff; do
9 echo "Searching for namespace: $ns";
10 # search in cxx files, excluding URE headers, plus some files with false positives
11 for file in $(git grep -l "^\s*using :*$ns::" *hxx *cxx \
12 ':!include/com/' \
13 ':!include/cppu/' \
14 ':!include/cppuhelper/' \
15 ':!include/osl/' \
16 ':!include/rtl/' \
17 ':!include/sal/' \
18 ':!include/salhelper/' \
19 ':!include/systools/' \
20 ':!include/typelib/' \
21 ':!include/uno/' \
22 ':!include/sfx2/stbitem.hxx' \
23 ':!sw/source/uibase/inc/maildispatcher.hxx'
24 ) ; do
25 for class in $(git grep -h "using :*$ns::" "$file" | rev | cut -d : -f -1 | rev | cut -d " " -f 1 | tr -d ";") ; do
26 if [ "$ns" == "com" ] ; then # com namespace may be mentioned in relevant header name too
27 if [[ $(grep -c "$class" "$file") -eq 1 || $(grep -c "$class" "$file") -le 2 && $(grep -c -e "$class".hpp -e "$class".hxx -e "$class".h "$file") -eq 1 ]]; then
28 echo "$file";
29 echo "Class name in above file is mentioned once or twice: $class";
31 else
32 if [ $(grep -c -F "$class" "$file") -eq 1 ]; then
33 echo "$file";
34 echo "Class name in above file is mentioned once: $class";
37 done
38 done
39 done
41 # vim: set noet sw=4 ts=4: