Affichage des articles dont le libellé est code. Afficher tous les articles
Affichage des articles dont le libellé est code. Afficher tous les articles

jeudi 29 février 2024

git pre-commit hooks library

cf.  https://codimd.nomadic-labs.com/p/YcXmjg1qv#/4


pre-commit is a tool that helps to configure git pre-commit hooks, with an abundance of already configured scripts


pre-commit install and configuration

  • Install in system

(apt-get / brew ) install pre-commit


  • install in repo 
then in each repo clone (set-up pre-commit for this repo):

pre-commit install


  • then (configure) edit .pre-commit-config.yaml


.pre-commit-config.yaml example  (from https://gitlab.com/tezos/tezos/-/blob/master/.pre-commit-config.yaml?ref_type=heads )

# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v3.2.0
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
  - repo: https://github.com/koalaman/shellcheck-precommit
    rev: v0.9.0
    hooks:
      - id: shellcheck
        args: [ "--external-sources" ]
  - repo: https://github.com/cisagov/pre-commit-shfmt
    rev: v0.0.2
    hooks:
      - id: shfmt
        # These settings must mirror the ones set in `scripts/lint.sh`.
        args: [ "-i", "2", "-sr", "-d" ]
  - repo: https://github.com/arenadotio/pre-commit-ocamlformat
    rev: 0439858
    hooks:
      - id: ocamlformat
        args: [ "-i" ]
  - repo: https://github.com/hadolint/hadolint
    rev: v2.9.3
    hooks:
      - id: hadolint-docker
  - repo: https://github.com/python-jsonschema/check-jsonschema
    rev: 0.28.0
    hooks:
      - id: check-gitlab-ci
        args: ["--verbose"]
        files: '(\.gitlab-ci\.yml|\.gitlab/ci/.*\.yml)'



General Notes about pre-commits


  • runs only against staged files

 

  • to run manually :

pre-commit run --all-files


  • to run 1 check specifically  (example : run only  1 plugin (shfmt) )

pre-commit run shfmt





mercredi 17 janvier 2024

Conventional Commits specification

 https://www.conventionalcommits.org/en/v1.0.0/

The Conventional Commits specification is a lightweight convention on top of commit messages. It provides an easy set of rules for creating an explicit commit history; which makes it easier to write automated tools on top of. This convention dovetails with SemVer, by describing the features, fixes, and breaking changes made in commit messages.



for example, to be used with commitlint : 

https://github.com/conventional-changelog/commitlint 



example, on gitlab-ci : https://gitlab.com/gitlab-org/gitlab-vscode-extension/-/merge_requests/85#587d266bb27a4dc3022bbed44dfa19849df3044c


or, at changelog level :

https://github.com/conventional-changelog/conventional-changelog


also cf. commitzen  :

https://github.com/commitizen/cz-cli

mercredi 21 juin 2023

The Not Rocket Science Rule Of Software Engineering: automatically maintain a repository of code that always passes all the tests

technicalities: "not rocket science" (the story of monotone and bors)

https://graydon2.dreamwidth.org/1597.html : 

The Not Rocket Science Rule Of Software Engineering:

automatically maintain a repository of code that always passes all the tests


mardi 28 septembre 2021

Code verifications / provers

C code + ACSL annotations --( Frama-C )--> "WhyML" Why3 format Proofs  --( Why3 analyser )--> proven code





  • ACSL By Example (good learning point with plenty of exmaples) Towards a Verified C Standard Library

https://www.mimuw.edu.pl/~alx/konstruowanie/ACSL-by-Example.pdf


  • Frama-C code analyser (Framework for Modular Analysis of C programs)

https://frama-c.com/
 https://frama-c.com/html/documentation.html 


https://frama-c.com/2016/11/22/Frama-C-and-ACSL-are-on-GitHub.html



  • Why3 / WhyML :

http://why3.lri.fr/

http://why3.lri.fr/doc/starting.html

mardi 19 août 2014

Code Style

This tools allows you to reformat your code in order to respect some particular coding rules.
This is for example what you want to use as a trigger in your svn, git or clearcase repo ;-)

http://astyle.sourceforge.net/


mardi 15 décembre 2009

Autour du code source et des programmes Java

SONAR :




Sonar est une plate-forme libre (LGPL v3) permettant de gérer la qualité du code source Java (exécution de tests unitaires, analyse de la couverture du code par ces tests, vérification du respect des règles de codage, complexité du code, etc.).
(depuis : dlfp )

http://sonar.codehaus.org/


FindBugs :




FindBugs is a program to find bugs in Java programs. It looks for instances of "bug patterns" code instances that are likely to be errors.


http://findbugs.sourceforge.net/
Éradiquer les lignes de code commentées

Forge des greffons Sonar


FindBugs serait en particulier beaucoup utilisé chez Google.

mercredi 25 février 2009

Quine : self-replicating program

Quines are programs who print their own source code when run.
For example in lua, this is a quine :

s="s=%qprint(s:format(s))"print(s:format(s))

lundi 9 février 2009

SLOCCount, compter le nombre de lignes de code

SLOCcount, permet de compter le nombre de ligne de code dans un répertoire
en déterminant automatiquement grace à différentes heuristiques de quel langage il s'agit.

Page web :
SLOCcount