Skip to content

Commit

Permalink
Adding a custom ruleset.
Browse files Browse the repository at this point in the history
Removing the license on readme mention
initially, as it is shown by GitHub.
  • Loading branch information
diemol committed Dec 30, 2023
1 parent 9c99ce4 commit feedd31
Show file tree
Hide file tree
Showing 2 changed files with 357 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const [owner] = repository.split('/')
const path = require('path')
const fs = require('fs')
const os = require('os')
const ruleSet = require('./ruleset.json')

const {
printResults,
Expand Down Expand Up @@ -58,7 +59,7 @@ async function main() {
if (!repository.archived) {
const tmpDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), `repolinter-${repository.name}-`))
await git.clone(repository.clone_url, tmpDir)
const repolinterConnect = await repolinter.lint(tmpDir) /*execute repolinter default ruleset*/
const repolinterConnect = await repolinter.lint(tmpDir, [], ruleSet)

/* Validates if Changelog rule passed, of not, search for releases */
await validateChangeLog(repolinterConnect.results, owner, repository.name)
Expand All @@ -69,7 +70,7 @@ async function main() {
/* Creates an array to check its length and sum all passing results without a loop */
const hasFailures =
repolinterConnect.results /* filter messages for what didn't passed */
.filter(result => !result.lintResult.passed).length > 0
.filter(result => !(result?.lintResult?.passed ?? false)).length > 0
if (!hasFailures) {
passingRepositories++
}
Expand Down
354 changes: 354 additions & 0 deletions src/ruleset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,354 @@
{
"$schema": "https://raw.githubusercontent.com/todogroup/repolinter/master/rulesets/schema.json",
"version": 2,
"axioms": {
"linguist": "language",
"licensee": "license",
"packagers": "packager"
},
"rules": {
"license-file-exists": {
"level": "error",
"rule": {
"type": "file-existence",
"options": {
"globsAny": [
"LICENSE*",
"COPYING*"
],
"nocase": true
}
}
},
"readme-file-exists": {
"level": "error",
"rule": {
"type": "file-existence",
"options": {
"globsAny": [
"README*"
],
"nocase": true
}
}
},
"contributing-file-exists": {
"level": "error",
"rule": {
"type": "file-existence",
"options": {
"globsAny": [
"{docs/,.github/,}CONTRIB*"
],
"nocase": true
}
}
},
"code-of-conduct-file-exists": {
"level": "error",
"rule": {
"type": "file-existence",
"options": {
"globsAny": [
"{docs/,.github/,}CODEOFCONDUCT*",
"{docs/,.github/,}CODE-OF-CONDUCT*",
"{docs/,.github/,}CODE_OF_CONDUCT*"
],
"nocase": true
}
}
},
"changelog-file-exists": {
"level": "error",
"rule": {
"type": "file-existence",
"options": {
"globsAny": [
"CHANGELOG*"
],
"nocase": true
}
}
},
"security-file-exists": {
"level": "error",
"rule": {
"type": "file-existence",
"options": {
"globsAny": [
"{docs/,.github/,}SECURITY.md"
]
}
}
},
"support-file-exists": {
"level": "error",
"rule": {
"type": "file-existence",
"options": {
"globsAny": [
"{docs/,.github/,}SUPPORT*"
],
"nocase": true
}
}
},
"binaries-not-present": {
"level": "error",
"rule": {
"type": "file-type-exclusion",
"options": {
"type": [
"**/*.exe",
"**/*.dll",
"!node_modules/**"
]
}
}
},
"test-directory-exists": {
"level": "error",
"rule": {
"type": "directory-existence",
"options": {
"globsAny": [
"**/test*",
"**/specs"
],
"nocase": true
}
}
},
"integrates-with-ci": {
"level": "error",
"rule": {
"type": "file-existence",
"options": {
"globsAny": [
".gitlab-ci.yml",
".travis.yml",
"appveyor.yml",
".appveyor.yml",
"circle.yml",
".circleci/config.yml",
"Jenkinsfile",
".drone.yml",
".github/workflows/*",
"azure-pipelines.yml"
]
}
}
},
"code-of-conduct-file-contains-email": {
"level": "error",
"rule": {
"type": "file-contents",
"options": {
"globsAll": [
"CODEOFCONDUCT*",
"CODE-OF-CONDUCT*",
"CODE_OF_CONDUCT*",
".github/CODEOFCONDUCT*",
".github/CODE-OF-CONDUCT*",
".github/CODE_OF_CONDUCT*"
],
"content": ".+@.+\\..+",
"flags": "i",
"human-readable-content": "email address"
}
}
},
"source-license-headers-exist": {
"level": "warning",
"rule": {
"type": "file-starts-with",
"options": {
"globsAll": [
"**/*.js",
"!node_modules/**"
],
"lineCount": 5,
"patterns": [
"Copyright",
"License"
],
"flags": "i"
}
}
},
"github-issue-template-exists": {
"level": "error",
"rule": {
"type": "file-existence",
"options": {
"dirs": true,
"globsAny": [
"ISSUE_TEMPLATE*",
".github/ISSUE_TEMPLATE*"
]
}
}
},
"github-pull-request-template-exists": {
"level": "error",
"rule": {
"type": "file-existence",
"options": {
"dirs": true,
"globsAny": [
"PULL_REQUEST_TEMPLATE*",
".github/PULL_REQUEST_TEMPLATE*"
]
}
}
},
"javascript-package-metadata-exists": {
"level": "error",
"where": [
"language=javascript"
],
"rule": {
"type": "file-existence",
"options": {
"globsAny": [
"package.json"
]
}
}
},
"ruby-package-metadata-exists": {
"level": "error",
"where": [
"language=ruby"
],
"rule": {
"type": "file-existence",
"options": {
"globsAny": [
"Gemfile"
]
}
}
},
"java-package-metadata-exists": {
"level": "error",
"where": [
"language=java"
],
"rule": {
"type": "file-existence",
"options": {
"globsAny": [
"pom.xml",
"build.xml",
"build.gradle"
]
}
}
},
"python-package-metadata-exists": {
"level": "error",
"where": [
"language=python"
],
"rule": {
"type": "file-existence",
"options": {
"globsAny": [
"setup.py",
"requirements.txt"
]
}
}
},
"objective-c-package-metadata-exists": {
"level": "error",
"where": [
"language=objective-c"
],
"rule": {
"type": "file-existence",
"options": {
"globsAny": [
"Cartfile",
"Podfile",
"*.podspec"
]
}
}
},
"swift-package-metadata-exists": {
"level": "error",
"where": [
"language=swift"
],
"rule": {
"type": "file-existence",
"options": {
"globsAny": [
"Package.swift"
]
}
}
},
"erlang-package-metadata-exists": {
"level": "error",
"where": [
"language=erlang"
],
"rule": {
"type": "file-existence",
"options": {
"globsAny": [
"rebar.config"
]
}
}
},
"elixir-package-metadata-exists": {
"level": "error",
"where": [
"language=elixir"
],
"rule": {
"type": "file-existence",
"options": {
"globsAny": [
"mix.exs"
]
}
}
},
"license-detectable-by-licensee": {
"level": "off",
"where": [
"license=*"
],
"rule": {
"type": "license-detectable-by-licensee",
"options": {}
}
},
"notice-file-exists": {
"level": "error",
"where": [
"license=Apache-2.0"
],
"rule": {
"type": "file-existence",
"options": {
"globsAny": [
"NOTICE*"
],
"fail-message": "The NOTICE file is described in section 4.4 of the Apache License version 2.0. Its presence is not mandated by the license itself, but by ASF policy."
}
}
},
"best-practices-badge-present": {
"level": "off",
"rule": {
"type": "best-practices-badge-present"
}
}
}
}

0 comments on commit feedd31

Please sign in to comment.