equals215/deepsentinel

View on GitHub

Showing 96 of 102 total issues

Function Handle has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring.
Open

func Handle(channel chan *Payload, dashboardOperator *dashboard.Operator) {
    log.Debug("Starting monitoring.Handle")
    var probeMap sync.Map
    var probeList = make([]string, 0)
    var timer = time.NewTimer(5 * time.Second)
Severity: Minor
Found in monitoring/monitoring.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 Handle has 69 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func Handle(channel chan *Payload, dashboardOperator *dashboard.Operator) {
    log.Debug("Starting monitoring.Handle")
    var probeMap sync.Map
    var probeList = make([]string, 0)
    var timer = time.NewTimer(5 * time.Second)
Severity: Minor
Found in monitoring/monitoring.go - About 1 hr to fix

    Function Cmd has 55 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func Cmd(rootCmd *cobra.Command) {
        var noAlerting bool
        var noDash bool
        payloadChannel := make(chan *monitoring.Payload)
    
    
    Severity: Minor
    Found in server/cmd.go - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                              if name == payload.Machine {
                                  probeList = append(probeList[:i], probeList[i+1:]...)
                                  break
                              }
      Severity: Major
      Found in monitoring/monitoring.go - About 45 mins to fix

        Function ExecuteConfigInstruction has 5 return statements (exceeds 4 allowed).
        Open

        func ExecuteConfigInstruction(instruction string, args []string) error {
            var message string
        
            message = fmt.Sprintf("%s=%s", instruction, strings.Join(args, ","))
            if instruction == "unregister" {
        Severity: Major
        Found in agent/config.go - About 35 mins to fix

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              if severity == "low" {
                  if Config.lowAlertProvider != nil {
                      log.Infof("Sending alert to low alert provider: %s", Config.lowAlertProvider.Name())
                      err := Config.lowAlertProvider.Send(category, component, severity)
                      if err != nil {
          Severity: Minor
          Found in alerting/alerting.go and 2 other locations - About 30 mins to fix
          alerting/alerting.go on lines 89..99
          alerting/alerting.go on lines 101..111

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 101.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              if severity == "high" {
                  if Config.highAlertProvider != nil {
                      log.Infof("Sending alert to high alert provider: %s", Config.highAlertProvider.Name())
                      err := Config.highAlertProvider.Send(category, component, severity)
                      if err != nil {
          Severity: Minor
          Found in alerting/alerting.go and 2 other locations - About 30 mins to fix
          alerting/alerting.go on lines 77..87
          alerting/alerting.go on lines 101..111

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 101.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              if severity == "panic" {
                  if Config.highAlertProvider != nil {
                      log.Infof("Sending alert to high alert provider: %s", Config.highAlertProvider.Name())
                      err := Config.highAlertProvider.Send(category, component, severity)
                      if err != nil {
          Severity: Minor
          Found in alerting/alerting.go and 2 other locations - About 30 mins to fix
          alerting/alerting.go on lines 77..87
          alerting/alerting.go on lines 89..99

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 101.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Function ServerAlert has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
          Open

          func ServerAlert(category, component, severity string) {
              log.Tracef("Alerting %s %s %s", category, component, severity)
          
              if severity == "low" {
                  if Config.lowAlertProvider != nil {
          Severity: Minor
          Found in alerting/alerting.go - About 25 mins 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

          Trailing spaces
          Open

          It can be disabled using the `--no-dashboard` flag on the `deepsentinel-server run` command.  
          Severity: Info
          Found in README.md by markdownlint

          MD009 - Trailing spaces

          Tags: whitespace

          Aliases: no-trailing-spaces

          Parameters: br_spaces (number; default: 0)

          This rule is triggered on any lines that end with whitespace. To fix this, find the line that is triggered and remove any trailing spaces from the end.

          The brspaces parameter allows an exception to this rule for a specific amount of trailing spaces used to insert an explicit line break/br element. For example, set brspaces to 2 to allow exactly 2 spaces at the end of a line.

          Note: you have to set brspaces to 2 or higher for this exception to take effect - you can't insert a br element with just a single trailing space, so if you set brspaces to 1, the exception will be disabled, just as if it was set to the default of 0.

          Inline HTML
          Open

          <h1 align="center">
          Severity: Info
          Found in README.md by markdownlint

          MD033 - Inline HTML

          Tags: html

          Aliases: no-inline-html

          This rule is triggered whenever raw HTML is used in a markdown document:

          Inline HTML header

          To fix this, use 'pure' markdown instead of including raw HTML:

          # Markdown header

          Rationale: Raw HTML is allowed in markdown, but this rule is included for those who want their documents to only include "pure" markdown, or for those who are rendering markdown documents in something other than HTML.

          Inline HTML
          Open

            <a href="http://www.amitmerchant.com/electron-markdownify"><img src="https://gist.githubusercontent.com/equals215/4cc46fe3225e4def80c1e915a5608c8d/raw/1b16d0817e88d8d5fa8c0730a8bfa66e072484c9/deepsentinel-crop.svg" alt="Markdownify" width="700"></a>
          Severity: Info
          Found in README.md by markdownlint

          MD033 - Inline HTML

          Tags: html

          Aliases: no-inline-html

          This rule is triggered whenever raw HTML is used in a markdown document:

          Inline HTML header

          To fix this, use 'pure' markdown instead of including raw HTML:

          # Markdown header

          Rationale: Raw HTML is allowed in markdown, but this rule is included for those who want their documents to only include "pure" markdown, or for those who are rendering markdown documents in something other than HTML.

          Trailing spaces
          Open

          As the agent is supposed to be run as close to the system as possible, it's not a good practice to run it inside a Docker container, hence why there is not Docker container for it 🤠  
          Severity: Info
          Found in README.md by markdownlint

          MD009 - Trailing spaces

          Tags: whitespace

          Aliases: no-trailing-spaces

          Parameters: br_spaces (number; default: 0)

          This rule is triggered on any lines that end with whitespace. To fix this, find the line that is triggered and remove any trailing spaces from the end.

          The brspaces parameter allows an exception to this rule for a specific amount of trailing spaces used to insert an explicit line break/br element. For example, set brspaces to 2 to allow exactly 2 spaces at the end of a line.

          Note: you have to set brspaces to 2 or higher for this exception to take effect - you can't insert a br element with just a single trailing space, so if you set brspaces to 1, the exception will be disabled, just as if it was set to the default of 0.

          Unordered list style
          Open

              - No actions required on the server-side
          Severity: Info
          Found in README.md by markdownlint

          MD004 - Unordered list style

          Tags: bullet, ul

          Aliases: ul-style

          Parameters: style (:consistent, :asterisk, :plus, :dash, :sublist; default :consistent)

          This rule is triggered when the symbols used in the document for unordered list items do not match the configured unordered list style:

          * Item 1
          + Item 2
          - Item 3

          To fix this issue, use the configured style for list items throughout the document:

          * Item 1
          * Item 2
          * Item 3

          Note: the configured list style can be a specific symbol to use (asterisk, plus, dash), or simply require that the usage be consistent within the document (consistent) or within a level (sublist).

          For sublist, each level must be consistent within a document, even if they are separate lists. So this is allowed:

          * Item 1
          * Item 2
            - Item 2a
              + Item 2a1
            - Item 2b
          * Item 3
          
          Other stuff
          
          * Item 1
          * Item 2

          But this is not allowed:

          * Item 1
          * Item 2
            - Item 2a
              + Item 2a1
            - Item 2b
          * Item 3
          
          Other stuff
          
          - Item 1
          - Item 2

          Ordered list item prefix
          Open

          3. Your agent should now be sending alive signals to the server. Check the server's logs to ensure that everything is setup properly.  
          Severity: Info
          Found in README.md by markdownlint

          MD029 - Ordered list item prefix

          Tags: ol

          Aliases: ol-prefix

          Parameters: style (:one, :ordered; default :one)

          This rule is triggered on ordered lists that do not either start with '1.' or do not have a prefix that increases in numerical order (depending on the configured style, which defaults to 'one').

          Example valid list if the style is configured as 'one':

          1. Do this.
          1. Do that.
          1. Done.

          Example valid list if the style is configured as 'ordered':

          1. Do this.
          2. Do that.
          3. Done.

          Trailing spaces
          Open

          2. Now you have to configure the agent using the `install` command :  
          Severity: Info
          Found in README.md by markdownlint

          MD009 - Trailing spaces

          Tags: whitespace

          Aliases: no-trailing-spaces

          Parameters: br_spaces (number; default: 0)

          This rule is triggered on any lines that end with whitespace. To fix this, find the line that is triggered and remove any trailing spaces from the end.

          The brspaces parameter allows an exception to this rule for a specific amount of trailing spaces used to insert an explicit line break/br element. For example, set brspaces to 2 to allow exactly 2 spaces at the end of a line.

          Note: you have to set brspaces to 2 or higher for this exception to take effect - you can't insert a br element with just a single trailing space, so if you set brspaces to 1, the exception will be disabled, just as if it was set to the default of 0.

          Line length
          Open

          **You will have to grab the auth token from either the logs or the config file bind mounted to your host**
          Severity: Info
          Found in README.md by markdownlint

          MD013 - Line length

          Tags: line_length

          Aliases: line-length

          Parameters: linelength, ignorecodeblocks, codeblocks, tables (number; default 80, boolean; default false, boolean; default true, boolean; default true)

          This rule is triggered when there are lines that are longer than the configured line length (default: 80 characters). To fix this, split the line up into multiple lines.

          This rule has an exception where there is no whitespace beyond the configured line length. This allows you to still include items such as long URLs without being forced to break them in the middle.

          You also have the option to exclude this rule for code blocks. To do this, set the ignore_code_blocks parameter to true. To exclude this rule for tables set the tables parameters to false. Setting the parameter code_blocks to false to exclude the rule for code blocks is deprecated and will be removed in a future release.

          Code blocks are included in this rule by default since it is often a requirement for document readability, and tentatively compatible with code rules. Still, some languages do not lend themselves to short lines.

          Headers should be surrounded by blank lines
          Open

          ## Install Server
          Severity: Info
          Found in README.md by markdownlint

          MD022 - Headers should be surrounded by blank lines

          Tags: headers, blank_lines

          Aliases: blanks-around-headers

          This rule is triggered when headers (any style) are either not preceded or not followed by a blank line:

          # Header 1
          Some text
          
          Some more text
          ## Header 2

          To fix this, ensure that all headers have a blank line both before and after (except where the header is at the beginning or end of the document):

          # Header 1
          
          Some text
          
          Some more text
          
          ## Header 2

          Rationale: Aside from aesthetic reasons, some parsers, including kramdown, will not parse headers that don't have a blank line before, and will parse them as regular text.

          Inline HTML
          Open

            <a href="http://www.amitmerchant.com/electron-markdownify"><img src="https://gist.githubusercontent.com/equals215/4cc46fe3225e4def80c1e915a5608c8d/raw/1b16d0817e88d8d5fa8c0730a8bfa66e072484c9/deepsentinel-crop.svg" alt="Markdownify" width="700"></a>
          Severity: Info
          Found in README.md by markdownlint

          MD033 - Inline HTML

          Tags: html

          Aliases: no-inline-html

          This rule is triggered whenever raw HTML is used in a markdown document:

          Inline HTML header

          To fix this, use 'pure' markdown instead of including raw HTML:

          # Markdown header

          Rationale: Raw HTML is allowed in markdown, but this rule is included for those who want their documents to only include "pure" markdown, or for those who are rendering markdown documents in something other than HTML.

          Inline HTML
          Open

            <a href="#dashboard">Dashboard</a> •
          Severity: Info
          Found in README.md by markdownlint

          MD033 - Inline HTML

          Tags: html

          Aliases: no-inline-html

          This rule is triggered whenever raw HTML is used in a markdown document:

          Inline HTML header

          To fix this, use 'pure' markdown instead of including raw HTML:

          # Markdown header

          Rationale: Raw HTML is allowed in markdown, but this rule is included for those who want their documents to only include "pure" markdown, or for those who are rendering markdown documents in something other than HTML.

          Severity
          Category
          Status
          Source
          Language