Skip to content

Commit

Permalink
Update Linting and buggy files (#48)
Browse files Browse the repository at this point in the history
Added linting
Added missing files
fixed typos
  • Loading branch information
Beakerboy authored Oct 31, 2023
1 parent a4429a4 commit aacf443
Show file tree
Hide file tree
Showing 16 changed files with 603 additions and 574 deletions.
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Declare files that will always have CRLF line endings on checkout.
*.cls text eol=crlf
*.frm text eol=crlf
*.bas text eol=crlf

# Denote all files that are truly binary and should not be modified.
*.frx binary
42 changes: 15 additions & 27 deletions .github/workflows/lint_vba.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,21 @@ jobs:
name: Test and Static Analysis
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['8.2']
python-version: ["3.11"]

steps:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2

- name: Set up Node
uses: actions/setup-node@v1
with:
node-version: '14.x'

- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup PHP Code Sniffer
run: |
composer require --no-install --no-update beakerboy/vba_tokenizer:dev-master
composer config repositories.beakerboy vcs https://github.com/Beakerboy/VBA_Tokenizer
composer update
- name: Lint
run: |
vendor/bin/phpcs --extensions=cls/vba,bas/vba,frm/vba --standard=vendor/beakerboy/vba_tokenizer/src/Standards/VBA src/Modules
vendor/bin/phpcs --extensions=cls/vba,bas/vba,frm/vba --standard=vendor/beakerboy/vba_tokenizer/src/Standards/VBA src/ClassModules
vendor/bin/phpcs --extensions=cls/vba,bas/vba,frm/vba --standard=vendor/beakerboy/vba_tokenizer/src/Standards/VBA src/Forms
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install antlr4-tools
wget https://raw.githubusercontent.com/Beakerboy/VBA_Tokenizer/ANTLR/VbaLint
chmod +x VbaLint
- name: Lint with antlr
run: |
./VbaLint
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/Beakerboy/VBA-SQL-Library.svg?branch=master)](https://travis-ci.org/Beakerboy/VBA-SQL-Library)
[![Lint VBA](https://github.com/Beakerboy/VBA-SQL-Library/actions/workflows/lint_vba.yml/badge.svg?branch=master)](https://github.com/Beakerboy/VBA-SQL-Library/actions/workflows/lint_vba.yml)
<a href="https://beakerboy.github.io/VBA-SQL-Library/"><img src="https://img.shields.io/badge/code-documented-green.svg"/></a>

VBA SQL Library
Expand Down
8 changes: 0 additions & 8 deletions deploy.sh

This file was deleted.

4 changes: 2 additions & 2 deletions src/ClassModules/SQLRecordset.cls
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ Public Function iSQLRecordset_GetRows(num As Integer)
iSQLRecordset_GetRows = orst.GetRows(num)
End Function

Public Property iSQLRecordset_EOF()
Property Get iSQLRecordset_EOF()
iSQLRecordset_EOF = orst.EOF
End Function
End Property
2 changes: 1 addition & 1 deletion src/ClassModules/iSQLRecordset.cls
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ Public Function State()
End Function

' Property: EOF
Public Property EOF()
Property Get EOF()

End Property
68 changes: 34 additions & 34 deletions src/Forms/Login.frm
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} Login
Caption = "Please Log In"
ClientHeight = 1920
ClientLeft = 120
ClientTop = 465
ClientWidth = 2295
OleObjectBlob = "Login.frx":0000
StartUpPosition = 1 'CenterOwner
End
Attribute VB_Name = "Login"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Ready As Boolean

Private Sub Form_Load()
Me.Show
Ready = False
Call Wait
'Label1.Visible = True
End Sub

Public Function Wait()
Do While Ready = False
DoEvents
Loop
End Function

Private Sub LoginButton_Click()
Ready = True
Me.Hide
End Sub
VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} Login
Caption = "Please Log In"
ClientHeight = 1920
ClientLeft = 120
ClientTop = 465
ClientWidth = 2295
OleObjectBlob = "Login.frx":0000
StartUpPosition = 1 'CenterOwner
End
Attribute VB_Name = "Login"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Ready As Boolean

Private Sub Form_Load()
Me.Show
Ready = False
Call Wait
'Label1.Visible = True
End Sub

Public Function Wait()
Do While Ready = False
DoEvents
Loop
End Function

Private Sub LoginButton_Click()
Ready = True
Me.Hide
End Sub
8 changes: 8 additions & 0 deletions testing/ClassModules/SQLTestRecordset.cls
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,11 @@ Public Function iSQLRecordset_GetValue(MyFieldname)
iSQLRecordset_GetValue = sQuery
End Function

Public Function iSQLRecordset_GetRows(num As Integer)
iSQLRecordset_GetRows = num
End Function

Property Get iSQLRecordset_EOF()
iSQLRecordset_EOF = False
End Property

150 changes: 75 additions & 75 deletions testing/ClassModules/SQLlibDatabaseTests.cls
Original file line number Diff line number Diff line change
@@ -1,75 +1,75 @@
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "SQLlibDatabaseTests"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Implements iTestCase

Dim MyDatabase As SQLDatabase
Dim MyRecordset As New SQLTestRecordset
Dim MyConnection As New SQLTestConnection
Dim SimpleInsert As SQLInsert
Dim TestCase As iTestCase

' Constructor: Class_Initialize
' Initialize class members
Private Sub Class_Initialize()
Set TestCase = CreateTestCase()
End Sub

Sub iTestCase_Setup()
Set MyDatabase = Create_SQLDatabase()

With MyDatabase
.DSN = "mydsn"
.Password = "Pa$$word"
.Username = "myusername"
Set .Recordset = MyRecordset
Set .Connection = MyConnection
End With


Set SimpleInsert = Create_SQLInsert
With SimpleInsert
.Table = "users"
.Fields = Array("id")
.Values = Array(1)
End With
End Sub

Sub iTestCase_TearDown()

End Sub

Function mssqlTest()
MyDatabase.DBType = "mssql"

Actual = MyDatabase.InsertGetNewId(SimpleInsert)
Expected = "SET NOCOUNT ON;INSERT INTO users (id) VALUES (1);SELECT SCOPE_IDENTITY() as somethingunique"
mssqlTest = AssertEquals(Actual, Expected)
End Function

Function psqlTest()
MyDatabase.DBType = "psql"

Actual = MyDatabase.InsertGetNewId(SimpleInsert, "id")
Expected = "INSERT INTO users (id) VALUES (1) RETURNING id"
psqlTest = AssertEquals(Actual, Expected)

End Function

' Sub: iTestCase_RunTest
' Run a specific test.
Public Sub iTestCase_RunTest(Test As String, Optional clsObj = Nothing)
TestCase.RunTest Test, Me
End Sub

' Sub: iTestCase_RunAllTests
' Run all tests.
Public Sub iTestCase_RunAllTests(Optional ByVal clsObj = Nothing)
TestCase.RunAllTests Me
End Sub
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "SQLlibDatabaseTests"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Implements iTestCase

Dim MyDatabase As SQLDatabase
Dim MyRecordset As New SQLTestRecordset
Dim MyConnection As New SQLTestConnection
Dim SimpleInsert As SQLInsert
Dim TestCase As iTestCase

' Constructor: Class_Initialize
' Initialize class members
Private Sub Class_Initialize()
Set TestCase = CreateTestCase()
End Sub

Sub iTestCase_Setup()
Set MyDatabase = Create_SQLDatabase()

With MyDatabase
.DSN = "mydsn"
.Password = "Pa$$word"
.Username = "myusername"
Set .Recordset = MyRecordset
Set .Connection = MyConnection
End With


Set SimpleInsert = Create_SQLInsert
With SimpleInsert
.Table = "users"
.Fields = Array("id")
.Values = Array(1)
End With
End Sub

Sub iTestCase_TearDown()

End Sub

Function mssqlTest()
MyDatabase.DBType = "mssql"

Actual = MyDatabase.InsertGetNewId(SimpleInsert)
Expected = "SET NOCOUNT ON;INSERT INTO users (id) VALUES (1);SELECT SCOPE_IDENTITY() as somethingunique"
mssqlTest = AssertEquals(Actual, Expected)
End Function

Function psqlTest()
MyDatabase.DBType = "psql"

Actual = MyDatabase.InsertGetNewId(SimpleInsert, "id")
Expected = "INSERT INTO users (id) VALUES (1) RETURNING id"
psqlTest = AssertEquals(Actual, Expected)

End Function

' Sub: iTestCase_RunTest
' Run a specific test.
Public Sub iTestCase_RunTest(Test As String, Optional clsObj = Nothing)
TestCase.RunTest Test, Me
End Sub

' Sub: iTestCase_RunAllTests
' Run all tests.
Public Sub iTestCase_RunAllTests(Optional ByVal clsObj = Nothing)
TestCase.RunAllTests Me
End Sub
Loading

0 comments on commit aacf443

Please sign in to comment.