hunterlong/statup

View on GitHub

Showing 284 of 423 total issues

Function CheckGrpc has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
Open

func CheckGrpc(s *Service, record bool) (*Service, error) {
    defer s.updateLastCheck()
    timer := prometheus.NewTimer(metrics.ServiceTimer(s.Name))
    defer timer.ObserveDuration()

Severity: Minor
Found in types/services/routine.go - About 3 hrs to fix

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

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
Severity: Major
Found in handlers/setup.go - About 2 hrs to fix

    Method Service.UptimeData has 90 lines of code (exceeds 50 allowed). Consider refactoring.
    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%,
    Severity: Major
    Found in types/services/methods.go - About 2 hrs to fix

      Function LoadConfigs has 89 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func LoadConfigs(cfgFile string) (*DbConfig, error) {
          writeAble, err := utils.DirWritable(utils.Directory)
          if err != nil {
              return nil, err
          }
      Severity: Major
      Found in types/configs/load.go - About 2 hrs to fix

        Function init has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        ContentEditableInput.prototype.init = function (display) {
            var this$1 = this;
        
          var input = this, cm = input.cm
          var div = input.div = display.lineDiv
        Severity: Major
        Found in frontend/public/js/codemirror.js - About 2 hrs to fix

          Function onContextMenu has 62 lines of code (exceeds 25 allowed). Consider refactoring.
          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.
          
          
          Severity: Major
          Found in frontend/public/js/codemirror.js - About 2 hrs to fix

            Function insertLineContent has 62 lines of code (exceeds 25 allowed). Consider refactoring.
            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)) }
            Severity: Major
            Found in frontend/public/js/codemirror.js - About 2 hrs to fix

              Function pollContent has 61 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              ContentEditableInput.prototype.pollContent = function () {
                if (this.readDOMTimeout != null) {
                  clearTimeout(this.readDOMTimeout)
                  this.readDOMTimeout = null
                }
              Severity: Major
              Found in frontend/public/js/codemirror.js - About 2 hrs to fix

                Function CheckGrpc has 84 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func CheckGrpc(s *Service, record bool) (*Service, error) {
                    defer s.updateLastCheck()
                    timer := prometheus.NewTimer(metrics.ServiceTimer(s.Name))
                    defer timer.ObserveDuration()
                
                
                Severity: Major
                Found in types/services/routine.go - About 2 hrs to fix

                  Function init has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  TextareaInput.prototype.init = function (display) {
                      var this$1 = this;
                  
                    var input = this, cm = this.cm
                    this.createField(display)
                  Severity: Major
                  Found in frontend/public/js/codemirror.js - About 2 hrs to fix

                    Function buildToken has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                    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
                    Severity: Major
                    Found in frontend/public/js/codemirror.js - About 2 hrs to fix

                      Consider simplifying this complex logical expression.
                      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) }
                      Severity: Critical
                      Found in frontend/public/js/codemirror.js - About 2 hrs to fix

                        Function regChange has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                        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 }
                        
                        
                        Severity: Major
                        Found in frontend/public/js/codemirror.js - About 2 hrs to fix

                          File mixin.js has 260 lines of code (exceeds 250 allowed). Consider refactoring.
                          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'
                          Severity: Minor
                          Found in frontend/src/mixin.js - About 2 hrs to fix

                            Function HttpRequest has 80 lines of code (exceeds 50 allowed). Consider refactoring.
                            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"
                            Severity: Major
                            Found in utils/utils.go - About 2 hrs to fix

                              Function makeChangeFromHistory has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                              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
                              Severity: Major
                              Found in frontend/public/js/codemirror.js - About 2 hrs to fix

                                Function CheckHttp has 78 lines of code (exceeds 50 allowed). Consider refactoring.
                                Open

                                func CheckHttp(s *Service, record bool) (*Service, error) {
                                    defer s.updateLastCheck()
                                    timer := prometheus.NewTimer(metrics.ServiceTimer(s.Name))
                                    defer timer.ObserveDuration()
                                
                                
                                Severity: Major
                                Found in types/services/routine.go - About 2 hrs to fix

                                  Function markText has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                                  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) }
                                  Severity: Major
                                  Found in frontend/public/js/codemirror.js - About 2 hrs to fix

                                    Function onDrop has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    function onDrop(e) {
                                      var cm = this
                                      clearDragCursor(cm)
                                      if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
                                        { return }
                                    Severity: Major
                                    Found in frontend/public/js/codemirror.js - About 2 hrs to fix

                                      Function findPosH has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                      function findPosH(doc, pos, dir, unit, visually) {
                                        var oldPos = pos
                                        var origDir = dir
                                        var lineObj = getLine(doc, pos.line)
                                        function findNextLine() {
                                      Severity: Major
                                      Found in frontend/public/js/codemirror.js - About 2 hrs to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language