Skip to content

Refactored & Added a Script to be Run Locally for a Project#15

Merged
bvw merged 12 commits into
masterfrom
script-to-run-linting-locally
Mar 9, 2023
Merged

Refactored & Added a Script to be Run Locally for a Project#15
bvw merged 12 commits into
masterfrom
script-to-run-linting-locally

Conversation

@nicky-johnstone
Copy link
Copy Markdown
Member

@nicky-johnstone nicky-johnstone commented Mar 2, 2023

Testing

tclsh all.tcl 
Tests running in interp:  /usr/bin/tclsh
Tests located in:  /home/nick/ci-development/tests/tcl
Tests running in:  /home/nick/ci-development/tests/tcl
Temporary files stored in /home/nick/ci-development/tests/tcl
Test files run in separate interpreters
Running tests that match:  *
Skipping test files that match:  l.*.test
Only running test files that match:  *.test
Tests began at Thu Mar 02 18:35:25 GMT 2023
linter.test
test_coverage.test

Tests ended at Thu Mar 02 18:35:25 GMT 2023
all.tcl:	Total	24	Passed	24	Skipped	0	Failed	0
Sourced 2 Test Files.

@nicky-johnstone
Copy link
Copy Markdown
Member Author

Updated with optional named args and support for a config file.

All args are optional in either the command line or config file.

Command line args take priority over the config file args.

If tcl_dir and test_dir are not specified in either the command line or the config file then the current working directory and all subdirectories will be searched for Tcl and test files.

The config file can exist in either the current working directory or in the home directory. Current working directory takes priority over the home directory.

Example usage:

cd ~/ci-development
tclsh ~/ci-development/scripts/linting.tcl -line_length 100 -file_length 500 -proc_length 80 -tcl_dir tcl -test_dir tests

tclsh ~/ci-development/scripts/linting.tcl

Example config files:

file_length = 1000
proc_length = 100
line_length = 90
tcl_dir = tcl
test_dir = test
file_length = 400
proc_length = 50
test_dir = tests

@nicky-johnstone
Copy link
Copy Markdown
Member Author

Example output:

tclsh ~/ci-development/scripts/linting.tcl -line_length 85
Checking for files that are more than 400 lines long.
---

0 files exceeding 400 lines found.

--------------------------------------------------

Checking line length is under 85 characters.
---
Line 79 in file /home/nick/ci-development/tcl/linter.tcl is 88 chars long - error $message [...
Line 143 in file /home/nick/ci-development/tcl/linter.tcl is 88 chars long - error $message [...
Line 272 in file /home/nick/ci-development/tcl/linter.tcl is 88 chars long - error $message [...
Line 136 in file /home/nick/ci-development/tcl/test_coverage.tcl is 89 chars long - #| i.e. test GET...
Line 273 in file /home/nick/ci-development/tcl/test_coverage.tcl is 87 chars long - dict set data pr...
Line 276 in file /home/nick/ci-development/tcl/test_coverage.tcl is 90 chars long - dict set data en...
Line 329 in file /home/nick/ci-development/tcl/test_coverage.tcl is 86 chars long - puts "The proc \...

7 lines exceeding 85 characters found.

--------------------------------------------------

Checking for procs that have bodies that are more than 80 lines long.
---

0 procs with bodies exceeding 80 lines found.

--------------------------------------------------

Checking for proc names that are not prefixed with the file name.
---

0 procs without file name as a prefix found.

--------------------------------------------------

Checking for procs that do not have at least one unit test.
---

0 procs that do not have a unit test found.

Comment thread Makefile Outdated
@nicky-johnstone
Copy link
Copy Markdown
Member Author

I've updated the Makefile so that a Tcl package called qcode-linter is created and installed alongside the qcode-linter script being set up.

I've tested the Makefile in a limited capacity on my dev box by running some of the shell commands. A full test of the Makefile will only be possible once the linting script is in the master branch and a release has been created.

@nicky-johnstone
Copy link
Copy Markdown
Member Author

Counts have been removed from the report procs.

Testing

  • Run each script via command line.
  • Run parts of Makefile to install qcode-linter script and qcode-linter Tcl package.
  • Run qcode-linter on this project.

Unit Tests

tclsh all.tcl
Tests running in interp:  /usr/bin/tclsh
Tests located in:  /home/nick/ci-development/tests/tcl
Tests running in:  /home/nick/ci-development/tests/tcl
Temporary files stored in /home/nick/ci-development/tests/tcl
Test files run in separate interpreters
Running tests that match:  *
Skipping test files that match:  l.*.test
Only running test files that match:  *.test
Tests began at Tue Mar 07 14:27:24 GMT 2023
linter.test
test_coverage.test

Tests ended at Tue Mar 07 14:27:24 GMT 2023
all.tcl:	Total	24	Passed	24	Skipped	0	Failed	0
Sourced 2 Test Files.

Comment thread scripts/linting.tcl Outdated
@nicky-johnstone
Copy link
Copy Markdown
Member Author

Testing

  • Run each script via command line.
  • Run parts of Makefile to install qcode-linter script and qcode-linter Tcl package.
  • Run qcode-linter on this project.

Unit Tests

Tests running in interp:  /usr/bin/tclsh
Tests located in:  /home/nick/ci-development/tests/tcl
Tests running in:  /home/nick/ci-development/tests/tcl
Temporary files stored in /home/nick/ci-development/tests/tcl
Test files run in separate interpreters
Running tests that match:  *
Skipping test files that match:  l.*.test
Only running test files that match:  *.test
Tests began at Wed Mar 08 18:16:08 GMT 2023
linter.test
test_coverage.test

Tests ended at Wed Mar 08 18:16:08 GMT 2023
all.tcl:	Total	25	Passed	25	Skipped	0	Failed	0
Sourced 2 Test Files.

@bvw bvw merged commit 9f1e351 into master Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants