Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linting and formatting code #75

Merged
merged 4 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file is part of preseq
#
# Copyright (C) 2024: Andrew D. Smith
#
# Authors: Andrew D. Smith
#
# This 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 software 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.

BasedOnStyle: LLVM
ColumnLimit: 80
IndentWidth: 2
AlwaysBreakAfterReturnType: TopLevel
ContinuationIndentWidth: 2
ConstructorInitializerIndentWidth: 2
BraceWrapping:
BeforeElse: true
BeforeCatch: true
BreakBeforeBraces: Custom
BreakConstructorInitializers: AfterColon
SpacesBeforeTrailingComments: 2
39 changes: 39 additions & 0 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This file is part of preseq
#
# Copyright (C) 2024: Andrew D. Smith
#
# Authors: Andrew D. Smith
#
# This 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 software 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.

name: Source formatting with clang-format

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

jobs:
clang-format:
runs-on: ubuntu-24.04

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install dependencies
run: sudo apt-get install -y clang-format

- name: Run clang-format
run: |
clang-format --dry-run -Werror $(git ls-files '*.*pp')
52 changes: 52 additions & 0 deletions .github/workflows/cpplint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This file is part of preseq
#
# Copyright (C) 2024: Andrew D. Smith
#
# Authors: Andrew D. Smith
#
# This 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 software 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.

name: Linting with cpplint

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:

jobs:
cpplint:
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ["3.12"]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Python setup ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install cpplint
run: |
python -m pip install --upgrade pip
pip install cpplint

- name: Check cpplint version
run: cpplint --version

- name: Run cpplint
run: |
cpplint --quiet --repository=. $(git ls-files '*.*pp')
28 changes: 28 additions & 0 deletions CPPLINT.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file is part of preseq
#
# Copyright (C) 2024: Andrew D. Smith
#
# Authors: Andrew D. Smith
#
# This 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 software 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.

set noparent
filter=-runtime/references
filter=-build/include_subdir
filter=-build/include_order
filter=-build/c++11
filter=-build/c++17
# Formatting below handled by clang-format
filter=-whitespace/line_length
filter=-whitespace/newline
filter=-readability/braces
filter=-whitespace/semicolon
filter=-whitespace/indent
37 changes: 37 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh
#
# Run 'autoreconf -i' to generate 'configure', 'Makefile.in', etc.
#
# The first time this is run on a new cloned git repo the configure
# script will not be present, only the configure.ac and
# Makefile.am. The rest must be generated by `autoreconf -i`.
#
# If you are working with a distribution (file ending with ".tar.gz"
# or similar) then this script should not be needed, and should not be
# present, as all the files should already exist. You should only run
# this script if you know what you are doing with autoreconf.
#
# This script will only work with an argument to confirm the help
# message has been read.

runautoreconf() {
autoreconf -i;
}

if test -d .git && test "$(basename "${PWD}")" = "preseq"
then
runautoreconf
exit 0
else
echo " It seems you are either attempting to run this script "
echo " from the wrong directory, or in a source tree that was "
echo " not obtained by cloning the preseq git repo. "
echo " "
echo " ./autogen.sh generates the configure script. Only run "
echo " "
echo " Only run this if you know what you are doing with "
echo " autoreconf and are simply avoiding doing that. If you "
echo " just want to use the software, download a release and "
echo " this script will not be needed. "
exit 1
fi
Loading
Loading