File: lint-no-trailing-newline-in-log-messages.sh

package info (click to toggle)
golang-github-pion-datachannel 1.5.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-backports, forky, sid, trixie
  • size: 232 kB
  • sloc: makefile: 2
file content (41 lines) | stat: -rwxr-xr-x 942 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env bash

#
# DO NOT EDIT THIS FILE
#
# It is automatically copied from https://github.com/pion/.goassets repository.
#
# If you want to update the shared CI config, send a PR to
# https://github.com/pion/.goassets instead of this repository.
#

set -e

# Disallow usages of functions that cause the program to exit in the library code
SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
if [ -f ${SCRIPT_PATH}/.ci.conf ]
then
  . ${SCRIPT_PATH}/.ci.conf
fi

files=$(
  find "$SCRIPT_PATH/.." -name "*.go" \
    | while read file
    do
      excluded=false
      for ex in $EXCLUDE_DIRECTORIES
      do
        if [[ $file == */$ex/* ]]
        then
          excluded=true
          break
        fi
      done
      $excluded || echo "$file"
    done
)

if grep -E '\.(Trace|Debug|Info|Warn|Error)f?\("[^"]*\\n"\)?' $files | grep -v -e 'nolint'; then
	echo "Log format strings should have trailing new-line"
	exit 1
fi