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

Code style additions #3651

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft

Code style additions #3651

wants to merge 7 commits into from

Conversation

AoifeHughes
Copy link
Collaborator

Summary

Addresses #3650 and also adds information following on from #1390

This PR adds a new section on pre-commit hooks to the "Code Style and Formatting" chapter.

It is also important to decide if the .pre-commit file added should be ran. If so then can we do it here (~500 files will be changed by having line-endings etc. corrected)

List of changes proposed in this PR (pull-request)

  • Added a new section titled "Pre-commit hooks" to the "Code Style and Formatting" chapter
  • Introduced the concept of pre-commit, its key features, and how to set it up in a project
  • Placed the new section between the "Automatic formatting" and "Online services providing software quality checks" sections

What should a reviewer concentrate their feedback on?

  • Does the new section fit well within the overall structure of the chapter?
  • Is the information on pre-commit presented clearly and accurately?
  • Are there any additional details or examples that should be included?

Acknowledging contributors

@AoifeHughes AoifeHughes added enhancement New feature or request book General tag for all edits related to chapters within the guides labels May 13, 2024
@AoifeHughes AoifeHughes self-assigned this May 13, 2024
Copy link

netlify bot commented May 13, 2024

Deploy Preview for the-turing-way ready!

Name Link
🔨 Latest commit 8cbdca7
🔍 Latest deploy log https://app.netlify.com/sites/the-turing-way/deploys/664750fd89fd5c0008cc961a
😎 Deploy Preview https://deploy-preview-3651--the-turing-way.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@AoifeHughes
Copy link
Collaborator Author

Actually this is kinda fun, adding the pre-commit file has flagged https://github.com/the-turing-way/the-turing-way/actions/runs/9063649234/job/24900034368?pr=3651 which I don't get why the spaces around hyphen thing is an issue here

@AoifeHughes
Copy link
Collaborator Author

Latest commit should be CRefed with #3650 (comment)

@AoifeHughes
Copy link
Collaborator Author

To make it easier for a reviewer, I think the only file that really needs checked over is:

@AoifeHughes
Copy link
Collaborator Author

@JimMadge would this be something you've capacity for to give a quick look over? I've already requested a review from @aleesteele too.

Copy link
Member

@JimMadge JimMadge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 🎉.

A few suggestions for the text and a question about the changed images.

I think the hooks you've added are uncontroversial. As long as CI will apply the changes, and we don't "force" users to add pre-commit to their workflow I think it will be a great addition for code quality 🙌.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also use Prettier for format Markdown/YAML/JSON.

I've had good experiences using it for websites written in Markdown before.
That might be a good thing to do in another PR though as it will likely make a lot of change (and might break the rendering of a few things).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what has happened here. Has the image been removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's still here

but it does seem broken? Lemme see if I can fix it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting that whitespace was tidied in svgs 😄.
It might be confusing, maybe we should exclude svgs from linting?


- Runs checks before each commit
- Supports a wide range of programming languages
- Configurable through a `.pre-commit-config.yaml` file in your repository
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(My opinion here)

It might be worth saying something about how pre-commit helps teams work together.
Git hooks have existed for ages, but the things pre-commit adds are,

  • Easily sharing hooks in the repo
  • Running hooks on the user side before commit/push instead of on the remote side

- Supports a wide range of programming languages
- Configurable through a `.pre-commit-config.yaml` file in your repository
- Extensible with custom hooks
- Integrates with version control systems like Git
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Links to the Glossary for VCS and Git would be good.


To use pre-commit:

1. Install pre-commit: `pip install pre-commit`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be tempted to link to pre-commits own install docs here.
(That and I don't like pip install outside of a venv 😄)

Comment on lines +72 to +82
```yaml
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
```

This configuration uses the `pre-commit-hooks` package for general-purpose checks and the black package for Python code formatting.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the file doesn't match the description? There isn't a hook for Black.

…tyle.md

Co-authored-by: Jim Madge <jmadge@turing.ac.uk>
@AoifeHughes
Copy link
Collaborator Author

TODO:

  • Fix pre-commit to ignore image files, e.g., gifs
  • Add notes about this to the chapter and how to customise pre-commit.
  • Check figures and fix them

AoifeHughes and others added 2 commits May 17, 2024 13:43
…tyle.md

Co-authored-by: Jim Madge <jmadge@turing.ac.uk>
…tyle.md

Co-authored-by: Jim Madge <jmadge@turing.ac.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
book General tag for all edits related to chapters within the guides enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants