Skip to content

Comments

chore(linters): Reorder linters, make hadolint ignores more specific#832

Merged
MaxymVlasov merged 11 commits intomasterfrom
hadolint_and_config
Mar 25, 2025
Merged

chore(linters): Reorder linters, make hadolint ignores more specific#832
MaxymVlasov merged 11 commits intomasterfrom
hadolint_and_config

Conversation

@MaxymVlasov
Copy link
Collaborator

@MaxymVlasov MaxymVlasov commented Mar 3, 2025

Split from #831

Hadolint supports its own config file, and that make able 3rd-party tools that utilize hadolint also known about specified config options, not pre-commit only

@coderabbitai
Copy link

coderabbitai bot commented Mar 3, 2025

📝 Walkthrough

Summary by CodeRabbit

  • Chores
    • Streamlined internal quality checks for a more efficient development process.
    • Enhanced container build instructions and dependency management for improved reliability in test environments.

Walkthrough

The pull request reorganizes the configuration for pre-commit linting and updates Dockerfile instructions. In the pre-commit configuration, the hadolint hook is reintroduced without previous ignore arguments, and a new Bash section with shfmt and shellcheck hooks is added. The YAML and JSON5 linter sections are streamlined, with obsolete comments removed. In the Dockerfiles, comments have been added to clarify linting rules for Docker RUN commands, and the testing Dockerfile now uses Alpine’s package manager (apk) to install datamash, simplifying the dependency installation process.

Changes

File(s) Summary
.pre-commit-config.yaml Reorganized linting hooks: reintroduced hadolint without ignore arguments; added new Bash section with shfmt and shellcheck hooks; streamlined YAML and JSON5 sections by removing obsolete comments and relocating entries.
Dockerfile Added comments to clarify Docker RUN command practices, explaining that runs should not be consolidated (DL3059) and noting a false positive for SC3037.
tests/Dockerfile Replaced the apt-based installation approach with apk to install datamash (version ~1.8), removed the installation of the time package and eliminated cleanup steps.

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Free

📥 Commits

Reviewing files that changed from the base of the PR and between edd0b91 and bfae853.

📒 Files selected for processing (1)
  • Dockerfile (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Dockerfile

Note

🎁 Summarized by CodeRabbit Free

Your organization has reached its limit of developer seats under the Pro Plan. For new users, CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please add seats to your subscription by visiting https://app.coderabbit.ai/login.If you believe this is a mistake and have available seats, please assign one to the pull request author through the subscription management page using the link above.

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Sadly, but hadolint ignore doesn't work if there any symbol
on the same line - ignore stop working.
That's why set justification on different line to hadolint ignore comment
# Cleanup
rm -rf /var/lib/apt/lists/*
RUN apk add --no-cache \
datamash=~1.8
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I found that we changed base image to alpine a long time ago :)

@MaxymVlasov MaxymVlasov changed the title chore(linters): Introduce hadolint config file and reorder linters chore(linters): Reorder linters, make hadolint ignores more specific Mar 21, 2025
yermulnik
yermulnik previously approved these changes Mar 21, 2025
@MaxymVlasov MaxymVlasov requested a review from yermulnik March 25, 2025 12:03

# Checking binaries versions and write it to debug file

# SC2086 - We do not need to quote "$F" variable, because it's not contain spaces
Copy link
Collaborator

Choose a reason for hiding this comment

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

It doesn't hurt to wrap in double quotes though and the benefit would be to not skip this check is we, by any chance, will add any new var into this code block.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If we add new vars here, it should be moved to separate .sh file, as it will become too complicated

Copy link
Collaborator

Choose a reason for hiding this comment

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

But the skipping check may remain and will disable checking it =)

Copy link
Contributor

Choose a reason for hiding this comment

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

It's always a good idea to use the "${VAR}" syntax for consistency and to prevent unexpected behavior happening due to changes in seemingly unrelated places not having been caught because of some forgotten linting suppression.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Despite the use of curly brackets is also encouraged by at least some shell linters I guess, I'd argue against it as curly brackets denote variable expansion syntax, which is pointless where no expansion is meant or expected.

yermulnik
yermulnik previously approved these changes Mar 25, 2025
Co-authored-by: George L. Yermulnik <yz@yz.kiev.ua>
@MaxymVlasov MaxymVlasov requested a review from yermulnik March 25, 2025 13:26

# Checking binaries versions and write it to debug file

# SC2086 - We do not need to quote "$F" variable, because it's not contain spaces
Copy link
Collaborator

Choose a reason for hiding this comment

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

But the skipping check may remain and will disable checking it =)

@MaxymVlasov MaxymVlasov merged commit f3c2648 into master Mar 25, 2025
47 checks passed
@MaxymVlasov MaxymVlasov deleted the hadolint_and_config branch March 25, 2025 19:02
@antonbabenko
Copy link
Owner

This PR is included in version 1.98.0 🎉

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.

4 participants