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

Lint markdown files #2574

Merged
merged 19 commits into from
Nov 22, 2023
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
26 changes: 26 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build

on:
pull_request:
push:
branches:
- main
workflow_dispatch:

defaults:
run:
working-directory: exercises

jobs:
build:
name: Check if tests compile cleanly with starter sources
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Set up JDK 1.17
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0
with:
java-version: 17
distribution: "temurin"
- name: Check if tests compile cleanly with starter sources
run: ./gradlew compileStarterTestJava --continue
27 changes: 12 additions & 15 deletions .github/workflows/gradle.yml → .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Gradle
name: Lint

on:
pull_request:
Expand All @@ -7,12 +7,12 @@ on:
- main
workflow_dispatch:

defaults:
run:
working-directory: exercises
permissions:
contents: read

jobs:
build:
java:
name: Lint Java files using Checkstyle
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
Expand All @@ -21,17 +21,14 @@ jobs:
with:
java-version: 17
distribution: "temurin"
- name: Check if tests compile cleanly with starter sources
run: ./gradlew compileStarterTestJava --continue
- name: Run checkstyle
run: ./gradlew check --exclude-task test --continue
working-directory: exercises

lint:
markdown:
name: Lint Markdown files
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Set up JDK 1.17
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0
with:
java-version: 17
distribution: "temurin"
- name: Run checkstyle
run: ./gradlew check --exclude-task test --continue
- name: Lint markdown
uses: DavidAnson/markdownlint-cli2-action@ed4dec634fd2ef689c7061d5647371d8248064f1
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:

jobs:
test:
name: Test all exercises using java-test-runner
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
Expand Down
21 changes: 21 additions & 0 deletions .markdownlint-cli2.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"globs": [
"concepts/**/*.md",
"docs/**/*.md",
"exercises/**/*.md",
"reference/**/*.md",
"*.md"
],
"ignores": [
// Deprecated exercises should never be updated
"exercises/concept/blackjack/**/*.md",
"exercises/practice/accumulate/**/*.md",
"exercises/practice/beer-song/**/*.md",
"exercises/practice/binary/**/*.md",
"exercises/practice/diffie-hellman/**/*.md",
"exercises/practice/hexadecimal/**/*.md",
"exercises/practice/octal/**/*.md",
"exercises/practice/strain/**/*.md",
"exercises/practice/trinary/**/*.md"
]
}
14 changes: 14 additions & 0 deletions .markdownlint.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Configuration is based on the Exercism Markdown specification, see:
// https://exercism.org/docs/building/markdown/markdown
//
// For information on writing markdownlint configuration see:
// https://github.com/DavidAnson/markdownlint/blob/main/README.md#optionsconfig
{
"MD004": {
"style": "dash" // Prefer hyphens for unordered lists
},
"MD013": false, // Exercism tends to break lines at sentence ends rather than at a column limit
"MD024": false, // The format for instructions.md requires repeated headings, e.g. "Task"
"MD033": false, // Inline HTML is allowed when used sparingly
"MD048": false // We want three backticks for codeblocks, but four tildes for special blocks.
}
12 changes: 9 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,15 @@ gradle compileStarterTestJava
When you finished your changes and checked that all validations have passed, it's time to commit and push them to your fork:

```sh
$ git add .
$ git commit -m "(An intention-revealing commit message)"
$ git push -u origin your-branch-name
git add .
```

```sh
git commit -m "(An intention-revealing commit message)"
```

```sh
git push -u origin your-branch-name
```

Then, open a Pull Request on the [exercism/java][track-repo] repository.
Expand Down
12 changes: 6 additions & 6 deletions POLICIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ References: [[1](https://github.com/exercism/java/issues/395#issue-215734887)]
### Name test class after class under test

> If you're testing a class called `SomeClassName` then your test class should be called `SomeClassNameTest`.

>
> The exception to this is if the tests are split into several test classes where each test class tests different functionality. In that case each class should be named `SomeClassNameFunctionalityTest` where `Functionality` is the name of the functionality to be tested in that class. See the [clock exercise](https://github.com/exercism/java/tree/main/exercises/practice/clock) as an example.

References: [[1](https://github.com/exercism/java/issues/697)]
Expand All @@ -131,11 +131,11 @@ References: [[1](https://github.com/exercism/java/issues/697)]
> According to the starter implementation policy, any exercise with difficulty 4 or lower should have starter implementation.
> Any exercise with difficulty 5 or above will have no starter implementation (unless its signature is very complicated).
> This could be confusing to users when tackling their first exercise with difficulty 5 when they are used to starter implementation being provided.

>
> Therefore a hints.md file should be added to the .meta directory for every exercise with difficulty 5.
> This file should explain what they need to do when there is no starter implementation.
> The files should all be the same so you can copy it from any other exercise with difficulty 5, e.g. [flatten-array](https://github.com/exercism/java/tree/main/exercises/pratice/flatten-array/.meta/hints.md).

>
> We add the file to every exercise with difficulty 5 because the structure of the track means that we don't know which exercise will be the first one without starter implementation that a user will be faced with.

References: [[1](https://github.com/exercism/java/issues/1075)]
Expand All @@ -154,14 +154,14 @@ References: [[1](https://github.com/exercism/java/issues/1389)]
> When an error has occured or a method can't return anything, the canonical data will just mark that as `"expected": null`.
> This is because error handling varies from language to language, so the canonical data is leaving it up to each language track to decide how to deal with those situations.
> It doesn't mean that the method needs to return `null`.

>
> In Java it's considered bad practice to return `null`.
> If you return `null` then the user of the method has to remember to check for `null` and they have to look at the implementation of the method to find out that this is necessary.

>
> It's considered best practice to deal with errors and unexpected circumstances by throwing exceptions.
> If you throw an exception then you force the user to deal with the problem.
> You can either define your own exception (see [the triangle exercise](https://github.com/exercism/java/blob/main/exercises/practice/triangle/.meta/src/reference/java/TriangleException.java) for an example) or use a predefined one (see [the collatz-conjecture exercise](https://github.com/exercism/java/blob/main/exercises/practice/collatz-conjecture/src/test/java/CollatzCalculatorTest.java) for an example).

>
> Another option is to use [Optionals](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html).
> This can be more suitable if the case you want to deal with isn't an exceptional occurence, but rather an expected scenario, e.g. a search method not finding what it was searching for.
> See [the word-search exercise](https://github.com/exercism/java/blob/main/exercises/practice/word-search/src/test/java/WordSearcherTest.java) for an example where `Optional` is used.
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Exercism Java Track

[![Configlet](https://github.com/exercism/java/actions/workflows/configlet.yml/badge.svg)](https://github.com/exercism/java/actions/workflows/configlet.yml)
[![Gradle](https://github.com/exercism/java/actions/workflows/gradle.yml/badge.svg)](https://github.com/exercism/java/actions/workflows/gradle.yml)
[![Lint](https://github.com/exercism/java/actions/workflows/lint.yml/badge.svg)](https://github.com/exercism/java/actions/workflows/lint.yml)
[![Build](https://github.com/exercism/java/actions/workflows/build.yml/badge.svg)](https://github.com/exercism/java/actions/workflows/build.yml)
[![Test](https://github.com/exercism/java/actions/workflows/test.yml/badge.svg)](https://github.com/exercism/java/actions/workflows/test.yml)

Source for Exercism Exercises in Java.
Expand Down
2 changes: 1 addition & 1 deletion concepts/booleans/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Booleans in Java are represented by the `boolean` type, which values can be either `true` or `false`.

Java supports three [boolean operators][operators]:
Java supports three [boolean operators][operators]:

- `!` (NOT): negates the boolean
- `&&` (AND): takes two booleans and results in true if they're both true
Expand Down
2 changes: 1 addition & 1 deletion concepts/booleans/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Java supports three boolean operators:
- `&&` (AND): takes two booleans and results in true if they're both true
- `||` (OR): results in true if any of the two booleans is true

**Examples**
## Examples

```java
!true // => false
Expand Down
6 changes: 3 additions & 3 deletions concepts/exceptions/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,23 @@ public class ATM {

In this example, when no exception is thrown, the following is printed:

```
```text
Withdrawing 10.0
Withdrawal succeeded
Current balance: 5.0
```

However, should the `bankAccount.withdraw(amount)` statement throw an `InsufficientBalanceException`, the following is printed:

```
```text
Withdrawing 10.0
Withdrawal failed: insufficient balance
Current balance: 5.0
```

Or, in case an unchecked exception is thrown by the `bankAccount.withdraw(amount)`, the following is printed:

```
```text
Withdrawing -10.0
Withdrawal failed: Cannot withdraw a negative amount
Current balance: 5.0
Expand Down
6 changes: 3 additions & 3 deletions concepts/exceptions/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,23 @@ public class ATM {

In this example, when no exception is thrown, the following is printed:

```
```text
Withdrawing 10.0
Withdrawal succeeded
Current balance: 5.0
```

However, should the `bankAccount.withdraw(amount)` statement throw an `InsufficientBalanceException`, the following is printed:

```
```text
Withdrawing 10.0
Withdrawal failed: insufficient balance
Current balance: 5.0
```

Or, in case an unchecked exception is thrown by the `bankAccount.withdraw(amount)`, the following is printed:

```
```text
Withdrawing -10.0
Withdrawal failed: Cannot withdraw a negative amount
Current balance: 5.0
Expand Down
2 changes: 1 addition & 1 deletion concepts/for-loops/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ for (int i = 1; i <= 4; i++) {

The output would be:

```
```text
square of 1 is 1
square of 2 is 4
square of 3 is 9
Expand Down
2 changes: 1 addition & 1 deletion concepts/foreach-loops/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ for(char vowel: vowels) {

which outputs:

```
```text
a
e
i
Expand Down
2 changes: 1 addition & 1 deletion concepts/foreach-loops/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ for(char vowel: vowels) {

which outputs:

```
```text
a
e
i
Expand Down
1 change: 0 additions & 1 deletion concepts/interfaces/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ Moreover, the concept of [polymorphism can be implemented through interfaces][in
[so-mocking-interfaces]: https://stackoverflow.com/a/9226437/96167
[comparable]: https://docs.oracle.com/javase/8/docs/api/java/lang/Comparable.html
[wiki-test-double]: https://en.wikipedia.org/wiki/Test_double
[wiki-polymorphism]: https://en.wikipedia.org/wiki/Polymorphism_(computer_science)
[wiki-namespaces]: https://en.wikipedia.org/wiki/Namespace
[wiki-loose-coupling]: https://en.wikipedia.org/wiki/Loose_coupling
[interfaces]: https://docs.oracle.com/javase/tutorial/java/concepts/interface.html
Expand Down
20 changes: 0 additions & 20 deletions config/exercise-readme-insert.md

This file was deleted.

19 changes: 0 additions & 19 deletions config/exercise_readme.go.tmpl

This file was deleted.

16 changes: 8 additions & 8 deletions docs/ABOUT.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# About

[Java](https://go.java/index.html) is among the most popular available programming languages, thanks to its versatility and compatibility.
[Java](https://go.java/index.html) is among the most popular available programming languages, thanks to its versatility and compatibility.
It is widely used for software development, mobile applications and developing larger systems.

Java was born in 1995 and is maintained by [Oracle](https://www.oracle.com/index.html).
Despite the fact that it isn't as young as some of the fresh languages out there, Java is still really popular.
It was designed to be fast, secure, reliable, beginner-friendly and highly portable.
This portability perk exists because Java is executed on a cross-platform compatible [Java Virtual Machine - JVM](https://en.wikipedia.org/wiki/Java_virtual_machine).
Android apps are also developed using Java, since the [Android Operating System](https://en.wikipedia.org/wiki/Android_(operating_system)) runs on a Java language environment.
Java was born in 1995 and is maintained by [Oracle](https://www.oracle.com/index.html).
Despite the fact that it isn't as young as some of the fresh languages out there, Java is still really popular.
It was designed to be fast, secure, reliable, beginner-friendly and highly portable.
This portability perk exists because Java is executed on a cross-platform compatible [Java Virtual Machine - JVM](https://en.wikipedia.org/wiki/Java_virtual_machine).
Android apps are also developed using Java, since the [Android Operating System](<https://en.wikipedia.org/wiki/Android_(operating_system)>) runs on a Java language environment.

The Java community is huge!
GitHub for example has over 1.5 million Java projects.
It's also worth mentioning that Java has the second largest community in [StackOverflow](https://stackoverflow.com/questions/tagged/java)!
GitHub for example has over 1.5 million Java projects.
It's also worth mentioning that Java has the second largest community in [StackOverflow](https://stackoverflow.com/questions/tagged/java)!
This is important because the larger a programming language community is, the more support you'd be likely to get.

Java also has a powerful and well-designed set of built-in [APIs - Application Programming Interfaces](https://docs.oracle.com/en/java/javase/11/docs/api/index.html), which can be used for various activities like Database connection, networking, I/O, XML parsing, utilities, and much more.
Expand Down
Loading