Showing 284 of 423 total issues
Function CheckGrpc
has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring. Open
Open
func CheckGrpc(s *Service, record bool) (*Service, error) {
defer s.updateLastCheck()
timer := prometheus.NewTimer(metrics.ServiceTimer(s.Name))
defer timer.ObserveDuration()
- 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 processSetupHandler
has 95 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func processSetupHandler(w http.ResponseWriter, r *http.Request) {
var err error
if core.App.Setup {
sendErrorJson(errors.New("Statping has already been setup"), w, r)
return
Method Service.UptimeData
has 90 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (s Service) UptimeData(hits []*hits.Hit, fails []*failures.Failure) (*UptimeSeries, error) {
if len(hits) == 0 {
return nil, errors.New("service does not have any successful hits")
}
// if theres no failures, then its been online 100%,
Function LoadConfigs
has 89 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func LoadConfigs(cfgFile string) (*DbConfig, error) {
writeAble, err := utils.DirWritable(utils.Directory)
if err != nil {
return nil, err
}
Function init
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
ContentEditableInput.prototype.init = function (display) {
var this$1 = this;
var input = this, cm = input.cm
var div = input.div = display.lineDiv
Function onContextMenu
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
TextareaInput.prototype.onContextMenu = function (e) {
var input = this, cm = input.cm, display = cm.display, te = input.textarea
var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop
if (!pos || presto) { return } // Opera is difficult.
Function insertLineContent
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function insertLineContent(line, builder, styles) {
var spans = line.markedSpans, allText = line.text, at = 0
if (!spans) {
for (var i$1 = 1; i$1 < styles.length; i$1+=2)
{ builder.addToken(builder, allText.slice(at, at = styles[i$1]), interpretTokenStyle(styles[i$1+1], builder.cm.options)) }
Function pollContent
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
ContentEditableInput.prototype.pollContent = function () {
if (this.readDOMTimeout != null) {
clearTimeout(this.readDOMTimeout)
this.readDOMTimeout = null
}
Function CheckGrpc
has 84 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func CheckGrpc(s *Service, record bool) (*Service, error) {
defer s.updateLastCheck()
timer := prometheus.NewTimer(metrics.ServiceTimer(s.Name))
defer timer.ObserveDuration()
Function init
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
TextareaInput.prototype.init = function (display) {
var this$1 = this;
var input = this, cm = this.cm
this.createField(display)
Function buildToken
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function buildToken(builder, text, style, startStyle, endStyle, title, css) {
if (!text) { return }
var displayText = builder.splitSpaces ? splitSpaces(text, builder.trailingSpace) : text
var special = builder.cm.state.specialChars, mustWrap = false
var content
Consider simplifying this complex logical expression. Open
Open
if (!(span.to != null && lineNo == from.line && from.ch >= span.to ||
span.from == null && lineNo != from.line ||
span.from != null && lineNo == to.line && span.from >= to.ch) &&
(!filter || filter(span.marker)))
{ found.push(span.marker.parent || span.marker) }
Function regChange
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function regChange(cm, from, to, lendiff) {
if (from == null) { from = cm.doc.first }
if (to == null) { to = cm.doc.first + cm.doc.size }
if (!lendiff) { lendiff = 0 }
File mixin.js
has 260 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import Vue from "vue";
const { startOfDay, startOfHour, startOfWeek, endOfMonth, endOfHour, startOfToday, startOfTomorrow, startOfYesterday, endOfYesterday, endOfTomorrow, endOfToday, endOfDay, startOfMonth, lastDayOfMonth, subSeconds, getUnixTime, fromUnixTime, differenceInSeconds, formatDistance, addMonths, addSeconds, isWithinInterval } = require('date-fns')
import formatDistanceToNow from 'date-fns/formatDistanceToNow'
import format from 'date-fns/format'
import parseISO from 'date-fns/parseISO'
Function HttpRequest
has 80 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func HttpRequest(endpoint, method string, contentType interface{}, headers []string, body io.Reader, timeout time.Duration, verifySSL bool, customTLS *tls.Config) ([]byte, *http.Response, error) {
var err error
var req *http.Request
if method == "" {
method = "GET"
Function makeChangeFromHistory
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function makeChangeFromHistory(doc, type, allowSelectionOnly) {
var suppress = doc.cm && doc.cm.state.suppressEdits
if (suppress && !allowSelectionOnly) { return }
var hist = doc.history, event, selAfter = doc.sel
Function CheckHttp
has 78 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func CheckHttp(s *Service, record bool) (*Service, error) {
defer s.updateLastCheck()
timer := prometheus.NewTimer(metrics.ServiceTimer(s.Name))
defer timer.ObserveDuration()
Function markText
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function markText(doc, from, to, options, type) {
// Shared markers (across linked documents) are handled separately
// (markTextShared will call out to this again, once per
// document).
if (options && options.shared) { return markTextShared(doc, from, to, options, type) }
Function onDrop
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function onDrop(e) {
var cm = this
clearDragCursor(cm)
if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
{ return }
Function findPosH
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function findPosH(doc, pos, dir, unit, visually) {
var oldPos = pos
var origDir = dir
var lineObj = getLine(doc, pos.line)
function findNextLine() {