Showing 55 of 190 total issues
Function _validateBody
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
_validateBody(body, checks = {}) {
const {
[MINIMUM_LENGTH]: {
enabled: shouldCheckLength = true,
length: requiredLength = DEFAULT_REQUIRED_LENGTH
Function fetchCommitsAndSetStatus
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
async fetchCommitsAndSetStatus({config, pull_request, repository, token}) {
/**
* Strategy: On every pull request that is opened or synced,
* check that all commit messages match at least one of one or more patterns.
*/
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function LoginNavHeader
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function LoginNavHeader() {
return <Navbar className="zpr-login-navbar">
<Navbar.Header>
<Navbar.Brand>
<img src={icon}/>
Function render
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const {selected, repos, fetchAll, filterRepos} = this.props
const {isFetching} = repos.status
const selectedRepo = repos.items[selected]
let content = null
Function requireAuth
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function requireAuth(WrappedComponent, redirect = '/login') {
function mapStateToProps(state) {
return {
isAuthenticated: state.auth.isAuthenticated
Function authenticate
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
async authenticate(req) {
const {headers} = req
const AUTH_HEADER = headers['authorization']
if (!AUTH_HEADER) this.fail({status: 400, reason: 'Missing Authorization header'})
const [type, token, ...rest] = AUTH_HEADER.split(' ')
Function getCommentStatsForConfig
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getCommentStatsForConfig(repository, comments, config, token) {
const that = this
async function checkComment(stats, comment) {
let matchesTotal = false
Function authenticate
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
async authenticate(req) {
const {headers} = req
const AUTH_HEADER = headers['authorization']
if (!AUTH_HEADER) this.fail({status: 400, reason: 'Missing Authorization header'})
const [type, token, ...rest] = AUTH_HEADER.split(' ')
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function renderStatic
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default async function renderStatic(ctx, next) {
const assets = await getStaticAssets()
const user = ctx.req.user ? ctx.req.user.json : {}
// at this point the cookie is guaranteed to exist due to previous middleware
Function render
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const {selected, isUpdating, filterBy} = this.props
const repos = this.sortedRepositories()
const header = <header>
Function onGetOne
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
async onGetOne(id, user = null, includeToken = false, autoSync = false) {
debug(`get Repository ${id}, autoSync ${autoSync}`)
let repository
try {
if (user) {
Function createShipper
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createShipper() {
switch (shipEngine) {
case 'file':
const FILENAME = nconf.get('AUDIT_FILENAME') || "audit.log"
const MAXSIZE = nconf.get('AUDIT_MAX_SIZE') || 10 ** 7 // 10 MB default max size
Function updateWebhookFor
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
async updateWebhookFor(user, repo, events, accessToken) {
debug(`${user}/${repo}: updating webhook with events: ${events.join(", ")}`)
let path = API_URL_TEMPLATES.HOOK.replace('${owner}', user).replace('${repo}', repo)
const HOOK_URL = nconf.get('HOOK_URL')
let hook_url = HOOK_URL ? HOOK_URL : nconf.get('HOST_ADDR') + '/api/hook'
Function init
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function init(options = {}) {
const passport = initPassport(options.PassportStrategy)
return app.use(generatePrometheusMiddleware(router, {
ignore: [/^\/repository/]
Function checkComment
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function checkComment(stats, comment) {
let matchesTotal = false
if (config.from) {
matchesTotal = await that.doesCommentMatchConfig(repository, comment, config.from, token)
if (matchesTotal) {
Function render
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const style = {
marginLeft: 15
}
const {check, onToggle} = this.props
Function decryptTokenHook
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function decryptTokenHook(thing) {
/**
* We check for the existence of a function `set` because if there is none,
* it means that we selected with raw=true and thus don't want to change
* the raw database content.
Function getPrMergedEvent
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getPrMergedEvent(auditEvent) {
const event_type = {
namespace: 'cloud.zalando.com',
name: 'pull-request-merged',
version: nconf.get('AUDIT_EVENT_VERSION') || 1
Function generateStatus
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
static generateStatus({approvals, vetos}, {minimum, groups}) {
if (vetos.length > 0) {
return {
description: `Vetoes: ${vetos.map(u => `@${u}`).join(', ')}.`,
state: 'failure',
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function doesCommentMatchConfig
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
async doesCommentMatchConfig(repository, comment, fromConfig, token) {
// persons must either be listed explicitly in users OR
// be a collaborator OR
// member of at least one of listed orgs
const {orgs, collaborators, users} = fromConfig
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"