Showing 284 of 423 total issues
Function CodeMirror
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function CodeMirror(place, options) {
var this$1 = this;
if (!(this instanceof CodeMirror)) { return new CodeMirror(place, options) }
Function tokenBase
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function tokenBase(stream, state) {
var ch = stream.next();
if (tokenHooks[ch]) {
var result = tokenHooks[ch](stream, state);
if (result !== false) return result;
Function tokenBase
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function tokenBase(stream, state) {
var ch = stream.next();
if (tokenHooks[ch]) {
var result = tokenHooks[ch](stream, state);
if (result !== false) return result;
Function Display
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function Display(place, doc, input) {
var d = this
this.input = input
// Covers bottom-right square when both scrollbars are present.
Consider simplifying this complex logical expression. Open
Open
} else if (stream.match(".Id") || stream.match(".Domain") || stream.match(".CreatedAt") ||
stream.match(".Name") || stream.match(".Downtime.Human") || stream.match(".Issue") || stream.match(".LastStatusCode") ||
stream.match(".Port") || stream.match(".FailuresLast24Hours") || stream.match(".PingTime")) {
return "var-sub-highlight"
} else if (stream.match("{{") || stream.match("}}")) {
Function moveVisually
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function moveVisually(cm, line, start, dir) {
var bidi = getOrder(line, cm.doc.direction)
if (!bidi) { return moveLogically(line, start, dir) }
if (start.ch >= line.text.length) {
start.ch = line.text.length
Function onScrollWheel
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function onScrollWheel(cm, e) {
var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y
var display = cm.display, scroll = display.scroller
// Quit if there's nothing to scroll here
Function Samples
has 73 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func Samples() error {
log.Infoln("Inserting Sample Incidents...")
incident1 := &Incident{
Title: "Github Issues",
Description: "There are new features for Statping, if you have any issues please visit the Github Repo.",
Function drawForLine
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function drawForLine(line, fromArg, toArg) {
var lineObj = getLine(doc, line)
var lineLen = lineObj.text.length
var start, end
function coords(ch, bias) {
Function updateDisplayIfNeeded
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function updateDisplayIfNeeded(cm, update) {
var display = cm.display, doc = cm.doc
if (update.editorIsHidden) {
resetView(cm)
Function domTextBetween
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function domTextBetween(cm, from, to, fromLine, toLine) {
var text = "", closing = false, lineSep = cm.doc.lineSeparator(), extraLinebreak = false
function recognizeMarker(id) { return function (marker) { return marker.id == id; } }
function close() {
if (closing) {
Function locateNodeInLineView
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function locateNodeInLineView(lineView, node, offset) {
var wrapper = lineView.text.firstChild, bad = false
if (!node || !contains(wrapper, node)) { return badPos(Pos(lineNo(lineView.line), 0), true) }
if (node == wrapper) {
bad = true
Function indentLine
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function indentLine(cm, n, how, aggressive) {
var doc = cm.doc, state
if (how == null) { how = "add" }
if (how == "smart") {
// Fall back to "prev" when the mode doesn't have an indentation
Function stretchSpansOverChange
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function stretchSpansOverChange(doc, change) {
if (change.full) { return null }
var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans
var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans
if (!oldFirst && !oldLast) { return null }
Function InitEnvs
has 72 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func InitEnvs() {
if Params != nil {
return
}
Params = viper.New()
Function makeChangeSingleDocInEditor
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function makeChangeSingleDocInEditor(cm, change, spans) {
var doc = cm.doc, display = cm.display, from = change.from, to = change.to
var recomputeMaxLength = false, checkWidthStart = from.line
if (!cm.options.lineWrapping) {
Function fromTextArea
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function fromTextArea(textarea, options) {
options = options ? copyObj(options) : {}
options.value = textarea.value
if (!options.tabindex && textarea.tabIndex)
{ options.tabindex = textarea.tabIndex }
Function measureCharInner
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function measureCharInner(cm, prepared, ch, bias) {
var place = nodeAndOffsetInLineMap(prepared.map, ch, bias)
var node = place.node, start = place.start, end = place.end, collapse = place.collapse
var rect
Function CheckHttp
has a Cognitive Complexity of 29 (exceeds 20 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()
- 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 settingsImportHandler
has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring. Open
Open
func settingsImportHandler(w http.ResponseWriter, r *http.Request) {
data, err := ioutil.ReadAll(r.Body)
if err != nil {
sendErrorJson(err, w, r)
return
- 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"