All Projects → globocom → gitlab-lint

globocom / gitlab-lint

Licence: BSD-3-Clause license
An open source gitlab linting utility

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to gitlab-lint

Reviewdog
🐶 Automated code review tool integrated with any code analysis tools regardless of programming language
Stars: ✭ 4,541 (+23800%)
Mutual labels:  lint, gitlab
gitlab-sonar-scanner
This project is no longer maintained
Stars: ✭ 80 (+321.05%)
Mutual labels:  gitlab
Whispers
Identify hardcoded secrets and dangerous behaviours
Stars: ✭ 66 (+247.37%)
Mutual labels:  lint
Secretlint
Pluggable linting tool to prevent committing credential.
Stars: ✭ 239 (+1157.89%)
Mutual labels:  lint
Ember Template Lint
Linter for Ember or Handlebars templates
Stars: ✭ 214 (+1026.32%)
Mutual labels:  lint
Lint Rules
A set of very opinionated lint rules.
Stars: ✭ 252 (+1226.32%)
Mutual labels:  lint
Add And Commit
Add & commit files from a path directly from GitHub Actions
Stars: ✭ 198 (+942.11%)
Mutual labels:  lint
log
Aplus Framework Log Library
Stars: ✭ 14 (-26.32%)
Mutual labels:  gitlab
landing-frontend
coala Landing Page - https://gitlab.com/coala/landing is needed as backend
Stars: ✭ 31 (+63.16%)
Mutual labels:  lint
Lin
Lin is an Android Lint tool made simple
Stars: ✭ 235 (+1136.84%)
Mutual labels:  lint
Fsharplint
Lint tool for F#
Stars: ✭ 224 (+1078.95%)
Mutual labels:  lint
Markdownlint
A Node.js style checker and lint tool for Markdown/CommonMark files.
Stars: ✭ 2,828 (+14784.21%)
Mutual labels:  lint
rpmlint
Tool for checking common errors in rpm packages
Stars: ✭ 112 (+489.47%)
Mutual labels:  lint
Sql Language Server
SQL Language Server
Stars: ✭ 210 (+1005.26%)
Mutual labels:  lint
vscode-lint
A VSCode configuration tool integrating Stylelint and Eslint
Stars: ✭ 60 (+215.79%)
Mutual labels:  lint
Grunt Recess
[DEPRECATED] Lint and minify CSS and LESS
Stars: ✭ 205 (+978.95%)
Mutual labels:  lint
D Scanner
Swiss-army knife for D source code
Stars: ✭ 221 (+1063.16%)
Mutual labels:  lint
Sql Lint
An SQL linter
Stars: ✭ 243 (+1178.95%)
Mutual labels:  lint
duplex
Duplicate code finder for Elixir
Stars: ✭ 20 (+5.26%)
Mutual labels:  lint
pathvalidate
A Python library to sanitize/validate a string such as filenames/file-paths/etc.
Stars: ✭ 139 (+631.58%)
Mutual labels:  lint

gitlab-lint API and collector

An open source gitlab linting utility

Frontend

https://github.com/globocom/gitlab-lint-react

How to install

Install dependencies

  • Golang
  • Docker
  • pre-commit
  • golangci-lint

Dev dependencies:

make setup

Create Gitlab access token

You should create a personal access token:

  1. Sign in to GitLab.
  2. In the top-right corner, select your avatar.
  3. Select Edit profile.
  4. In the left sidebar, select Access Tokens.
  5. Choose a name and optional expiry date for the token.
  6. Choose the read_api scope.
  7. Select Create personal access token.
  8. Save the personal access token somewhere safe. If you navigate away or refresh your page, and you did not save the token, you must create a new one.

Set the following environment variable with your token:

More info at Personal access tokens

export GITLAB_TOKEN="token"

Run it

make run-docker

Collecting the data

make collector

Managing rules

What are rules

Rules are how gitlab-lint knows what to look for on each processed project.

Take for an example the Empty Repository rule: its goal is to check if the current project houses an empty repository.

Creating new rules

Rules must implement the Ruler interface and they must have at least the following fields on their struct:

type Ruler interface {
	Run(client *gitlab.Client, p *gitlab.Project) bool
	GetSlug() string
	GetLevel() string
}
type MyAwesomeRule struct {
	Description string `json:"description"`
	ID          string `json:"ruleId"`
	Level       string `json:"level"`
	Name        string `json:"name"`
}

A good practice is to also have a NewMyAwesomeRule() function that returns an instatiaded rule's struct.

Notice that ID and GetSlug() should return a unique value to identify your rule.

Also, there's already a couple of pre-determined Levels on levels. We must use those instead of random strings.

Registering rules

After creating the rule itself, we must register it so it's considered when we parse the projects. In order to do it, we should just add it to the init() function on my_registry, just like so:

func init() {
	MyRegistry.AddRule(NewMyAwesomeRule())
	...
}

Then, you should be able to save (or recompile, if running a binary) and check your new rule being returned by running a GET to /api/v1/rules:

[
  {
    "description": "",
    "ruleId": "my-awesome-rule",
    "level": "error",
    "name": "My Awesome Rule"
  }
]

Contribute

Fork the repository and send your pull-requests.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].