Skip to content
Draft
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ rt/test/save/ZSTRMAC2.[mM][lL][cC]
**/*.[xX][lL][sS]
**/*.[xX][lL][sS][xX]
**/*.[xX][mM][lL]
!src/**/*.[xX][mM][lL]

# Backup and junk files
macold/
Expand Down
10 changes: 10 additions & 0 deletions bat/BLDJAR.BAT
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ shift /1
goto opt_loop
:options_ok

rem download linter jar
if not exist "build\checkstyle" mkdir build\checkstyle
if not exist "build\checkstyle\checkstyle-all.jar" powershell -NoProfile -ExecutionPolicy Bypass -File "bat\GetCheckStyle.ps1"
if not exist "build\checkstyle\checkstyle-all.jar" goto return || rem download must have failed - cannot continue
java -jar build\checkstyle\checkstyle-all.jar --version

rem run the linter
java -jar build\checkstyle\checkstyle-all.jar -c src\checkstyle.xml src
if %ERRORLEVEL% NEQ 0 goto return

rem prepare to compile java code and create jar file
if not exist ".\jar\" mkdir jar
cd jar
Expand Down
39 changes: 39 additions & 0 deletions bat/GetCheckStyle.PS1
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Suppress Invoke-WebRequest's built-in progress bar
$ProgressPreference = 'SilentlyContinue'

# Request latest release information
$apiUrl = 'https://api.github.com/repos/checkstyle/checkstyle/releases/latest'
$release = Invoke-RestMethod -Uri $apiUrl -Headers @{ 'User-Agent' = 'z390-build' }

# Tag is usually "checkstyle-13.4.2"
$tag = $release.tag_name

$asset = $release.assets | Where-Object { $_.name -match '-all\.jar$' } | Select-Object -First 1
if (-not $asset) {
Write-Host "No -all.jar asset found for $tag" -ForegroundColor Red
exit 1
}

$uri = $asset.browser_download_url
$outFile = "build\checkstyle\checkstyle-all.jar"
$versionFile = 'build\checkstyle\version.txt'

# Issue status message
Write-Host "Downloading linter from checkstyle repository on github.com..."

# Define our own progress bar
Write-Progress -Activity "Download" -Status $uri -PercentComplete 0

# Download linter jar and report results
try {
Invoke-WebRequest -Uri $uri -OutFile $outFile -UseBasicParsing
$tag | Set-Content -Path $versionFile -NoNewline
Write-Progress -Activity "Download" -Completed
Write-Host "Download finished: $tag"
exit 0
}
catch {
Write-Progress -Activity "Download" -Completed
Write-Host "Download failed: $($_.Exception.Message)" -ForegroundColor Red
exit 1
}
2 changes: 0 additions & 2 deletions src/az390.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.RandomAccessFile;
import java.lang.reflect.Array;
import java.math.BigDecimal;
Expand Down
83 changes: 83 additions & 0 deletions src/checkstyle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<!-- Disallow tabs for indentation -->
<module name="FileTabCharacter">
<property name="eachLine" value="true"/><!-- use true to report every tab -->
<property name="fileExtensions" value="java"/>
</module>

<!-- Disallow trailing whitespace -->
<module name="RegexpSingleline">
<property name="format" value="\s+$"/>
<property name="message" value="Line has trailing whitespace."/>
<property name="fileExtensions" value="java"/>
</module>

<module name="TreeWalker">
<!-- File name must match class definition -->
<module name="OuterTypeFilename"/>
<!-- Flag unused imports -->
<module name="UnusedImports"/>
<!-- Enforce indent of 4 spaces per nesting level -->
<module name="Indentation">
<property name="basicOffset" value="4"/>
<property name="braceAdjustment" value="0"/>
<property name="caseIndent" value="0"/>
<property name="throwsIndent" value="4"/>
<property name="lineWrappingIndentation" value="4"/>
<property name="arrayInitIndent" value="4"/>
</module>
<!-- Three blank lines required before each class and method/function -->
<module name="EmptyLineSeparator">
<property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF"/>
<property name="allowNoEmptyLineBetweenFields" value="true"/><!-- Require at least one blank line -->
<property name="allowMultipleEmptyLines" value="true"/><!-- Allow more than one blank line -->
</module>
<!-- Open brace must be at end of a line -->
<module name="LeftCurly">
<property name="option" value="eol"/>
</module>
<module name="WhitespaceAround">
<property name="tokens" value="LCURLY"/>
<property name="allowEmptyMethods" value="false"/>
<property name="allowEmptyConstructors" value="true"/>
<property name="allowEmptyTypes" value="false"/>
<property name="allowEmptyLoops" value="false"/>
<property name="allowEmptyLambdas" value="false"/>
<property name="allowEmptyCatches" value="false"/>
</module>
<!-- Closing brace must be at proper indent -->
<module name="RightCurly">
<property name="option" value="same"/><!-- allow `} else {` -->
</module>
<!-- JavadocMethod allows more specific and stricter checks -->
<!-- For now, we'll use the two below checks -->
<!-- Require Javadoc on member fields (all access levels) -->
<module name="JavadocVariable">
<property name="accessModifiers" value="public, protected, package, private"/>
</module>
<!-- Require Javadoc on methods and constructors (all access levels) -->
<module name="MissingJavadocMethod">
<property name="scope" value="private"/>
</module>
</module>

<!-- In addition to EmptyLineSeparator above, require three blank lines as a class/method separator -->
<!-- Require three empty lines after `}` marker -->
<module name="RegexpMultiline">
<property name="matchAcrossLines" value="true"/>
<property name="format" value="(?m)\*/\r?\n(?:\r?\n){0,2}[ \t]*/\*\*\r?\n[ \t]*\*"/>
<property name="message" value="Need 3 empty lines before Javadoc (after '}')."/>
<property name="fileExtensions" value="java"/>
</module>
<!-- Require three empty lines after the last import -->
<module name="RegexpMultiline">
<property name="matchAcrossLines" value="true"/>
<property name="format" value="(?m)^import\s+[^;]+;\r?\n(?:\r?\n){0,2}[ \t]*/\*\*"/>
<property name="message" value="Need 3 empty lines before class Javadoc (after imports)."/>
<property name="fileExtensions" value="java"/>
</module>
</module>
2 changes: 0 additions & 2 deletions src/mz390.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.lang.reflect.Array;
import java.text.SimpleDateFormat;
import java.util.Arrays;
Expand Down
Loading