Skip to content

Commit

Permalink
Merge pull request #12 from keyhr/master
Browse files Browse the repository at this point in the history
Fixed unnecessary void inserted to empty argument function call
  • Loading branch information
cacharle authored Jan 29, 2022
2 parents 4b61fa2 + 5ef53eb commit 70e283b
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 5 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/python-package-develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: CI-Dev

on:
push:
branches: [ develop ]
paths-ignore:
- 'License'
- 'README.md'
pull_request:
branches: [ develop ]
paths-ignore:
- 'License'
- 'README.md'

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements-dev.txt
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
python -m pip install -e .
- name: Lint with flake8
run: |
flake8 c_formatter_42
- name: Test with pytest
run: |
pytest -vvv
- name: Static type checking with mypy
run: |
mypy c_formatter_42
2 changes: 1 addition & 1 deletion c_formatter_42/formatters/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def remove_multiline_condition_space(content: str) -> str:

def insert_void(content: str) -> str:
return re.sub(
r"(?P<funcdef>[0-9a-zA-Z_]*\t+[0-9a-zA-Z_]*\s*)\(\s*\)",
r"(?P<funcdef>[0-9a-zA-Z_]+\t+[0-9a-zA-Z_]*\s*)\(\s*\)",
lambda match: "{}({})".format(match.group("funcdef"), "void"),
content,
)
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = c_formatter_42
version = 0.1.1
version = 0.1.2
description = formatting tool complient with 42 school's norm
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down
8 changes: 5 additions & 3 deletions tests/formatters/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ def test_run_space_in_condition():
def test_insert_void():
assert "int main()" == insert_void("int main()")
assert "void func ( )" == insert_void("void func ( )")
assert "int main(void)" == insert_void("int main()")
assert "void func (void)" == insert_void("void func ( )")
assert "void func (void)" == insert_void("void func ( )")
assert "int\tmain(void)" == insert_void("int\tmain()")
assert "void\tfunc (void)" == insert_void("void\tfunc ( )")
assert "void\t\tfunc (void)" == insert_void("void\t\tfunc ( )")
assert "\t(void *)foo()" == insert_void("\t(void *)foo()")
assert "\tfoo()" == insert_void("\tfoo()")

0 comments on commit 70e283b

Please sign in to comment.