Showing 55 of 190 total issues
File GithubService.js
has 446 lines of code (exceeds 250 allowed). Consider refactoring. Open
import path from 'path'
import nconf from '../nconf'
import { Counter } from 'prom-client'
import GithubServiceError, { GithubBranchProtectedError } from './GithubServiceError'
import { joinURL, promiseFirst, decode, encode, getIn, toGenericComment } from '../../common/util'
Function render
has 138 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const animationProps = {
width: 300,
height: 200,
Function repo
has 133 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function repo(router) {
return router
.get('/api/repos/:id', requireAuth, async(ctx) => {
try {
const query = qs.parse(url.parse(ctx.req.url).query)
Function execute
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
async execute(config, event, hookPayload, token, dbRepoId) {
const {action, repository, pull_request, number, issue} = hookPayload
const repoName = repository.name
const user = repository.owner.login
const {minimum} = config.approvals
- 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 execute
has 118 lines of code (exceeds 25 allowed). Consider refactoring. Open
async execute(config, event, hookPayload, token, dbRepoId) {
const {action, repository, pull_request, number, issue} = hookPayload
const repoName = repository.name
const user = repository.owner.login
const {minimum} = config.approvals
GithubService
has 36 functions (exceeds 20 allowed). Consider refactoring. Open
export class GithubService {
getOptions(method, path, body, accessToken, headers = {}) {
headers['User-Agent'] = `Zappr (+${nconf.get('HOST_ADDR')})`
if (accessToken) {
File Approval.js
has 348 lines of code (exceeds 250 allowed). Consider refactoring. Open
import Check from './Check'
import AuditEvent from '../service/audit/AuditEvent'
import { logger, formatDate } from '../../common/debug'
import { promiseReduce, getIn, toGenericComment } from '../../common/util'
import * as EVENTS from '../model/GithubEvents'
Function handleGithubWebhook
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
async handleGithubWebhook(dbRepo, checkArgs) {
const {event, payload, config} = checkArgs
const owner = dbRepo.json.owner.login
const name = dbRepo.json.name
const tokens = getTokens(dbRepo)
- 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 handleGithubWebhook
has 87 lines of code (exceeds 25 allowed). Consider refactoring. Open
async handleGithubWebhook(dbRepo, checkArgs) {
const {event, payload, config} = checkArgs
const owner = dbRepo.json.owner.login
const name = dbRepo.json.name
const tokens = getTokens(dbRepo)
Function render
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const {displayName, username, html_url, avatar_url} = this.props.user
const style = {
logo: {
marginTop: '-1px',
Function handleExistingPullRequests
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
async handleExistingPullRequests(dbRepo, checkType, {config, token}) {
const PR_TYPES = [
Approval.TYPE,
Specification.TYPE,
PullRequestMilestone.TYPE,
Function render
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
if (!this.props.repository.full_name) return null
const {repository, checks, validations} = this.props
const { isRefreshingToken } = checks;
Function processedPullRequests
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
const processedPullRequests = openPullRequests.map(async pullRequest => {
const dbPR = await this.pullRequestHandler.onGet(dbRepo.id, pullRequest.number)
switch (checkType) {
case Approval.TYPE:
return this.approval.fetchApprovalsAndSetStatus(
Function onGetOne
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
async onGetOne(id, user = null, includeToken = false, autoSync = false) {
debug(`get Repository ${id}, autoSync ${autoSync}`)
let repository
try {
if (user) {
- 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 handleGithubApiError
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
handleGithubApiError(statusCode, response) {
if (!this.isOK(statusCode)) {
if (statusCode >= 400 && statusCode <= 499) {
if (method !== 'GET' || statusCode !== 404) {
// only log 4xx if not GET 404 (happens often during zappr.yaml file check
- 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 decryptTokenHook
has a Cognitive Complexity of 14 (exceeds 5 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.
- 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 fetchPath
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
async fetchPath(method, path, payload, accessToken, headers = {}) {
const options = this.getOptions(method, path, payload, accessToken, headers)
const [response, body] = await request(options)
const {statusCode} = response || {}
CallCounter.inc({type: 'total'}, 1)
- 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 init
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function init(Strategy = GithubStrategy) {
const GITHUB_CLIENT_ID = nconf.get('GITHUB_CLIENT_ID')
const GITHUB_CLIENT_SECRET = nconf.get('GITHUB_CLIENT_SECRET')
const GITHUB_UI_URL = nconf.get('GITHUB_UI_URL')
const GITHUB_API_URL = nconf.get('GITHUB_API_URL')
Function countApprovalsAndVetos
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
async countApprovalsAndVetos(repository, pull_request, comments, config, token) {
const ignore = await this.fetchIgnoredUsers(repository, pull_request, config, token)
const approvalPattern = config.pattern
const vetoPattern = _.get(config, 'veto.pattern')
Function generateStatus
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
static generateStatus({approvals, vetos}, {minimum, groups}) {
if (vetos.length > 0) {
return {
description: `Vetoes: ${vetos.map(u => `@${u}`).join(', ')}.`,
state: 'failure',