gregoryv/draw

View on GitHub

Showing 22 of 22 total issues

Function NewProjectArticle has 141 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func NewProjectArticle() *Element {
    nav := Nav(H4("Table of contents"))
    article := Article(
        H1("Draw - programming software design diagrams"),

Severity: Major
Found in docs/package.go - About 4 hrs to fix

    Method SequenceDiagram.WriteSVG has 104 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (d *SequenceDiagram) WriteSVG(w io.Writer) error {
        var (
            colWidth = d.ColWidth
    
            top = d.top()
    Severity: Major
    Found in design/seqdia.go - About 3 hrs to fix

      Function Theme has 68 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func Theme() *CSS {
          css := NewCSS()
          css.Import("https://fonts.googleapis.com/css2?family=Inconsolata&family=Source+Sans+Pro&family=Source+Serif+Pro:wght@600")
          css.Import("https://fonts.googleapis.com/css2?family=Inconsolata&family=Lancelot&family=Open+Sans")
          css.Style("html, body",
      Severity: Minor
      Found in docs/theme.go - About 1 hr to fix

        Method ClassDiagram.HideRealizations has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
        Open

        func (d *ClassDiagram) HideRealizations() {
            for _, struct_ := range d.structs {
                for _, iface := range d.interfaces {
                    if reflect.PtrTo(struct_.t).Implements(iface.t) {
                        // Hide interface methods as they are visible
        Severity: Minor
        Found in design/classdia.go - About 1 hr 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

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

        func (a *Line) Width() int {
            v := []int{intAbs(a.Start.X - a.End.X)}
            if a.Head != nil {
                v = append(v, a.Head.Width())
            }
        Severity: Major
        Found in shape/line.go and 1 other location - About 1 hr to fix
        shape/line.go on lines 169..178

        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 136.

        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 2 locations. Consider refactoring.
        Open

        func (a *Line) Height() int {
            v := []int{intAbs(a.Start.Y - a.End.Y)}
            if a.Head != nil {
                v = append(v, a.Head.Height())
            }
        Severity: Major
        Found in shape/line.go and 1 other location - About 1 hr to fix
        shape/line.go on lines 180..189

        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 136.

        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 ExampleDiagram has 51 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func ExampleDiagram() *design.Diagram {
            var (
                record     = shape.NewRecord("Record")
                x, y       = 130, 80
                q1arrow    = shape.NewArrow(x, y, x+50, y-10)
        Severity: Minor
        Found in docs/example_diagrams.go - About 1 hr to fix

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

          func (a *Adjuster) LeftOf(o Shape, space ...int) *Adjuster {
              next := o
              for _, s := range a.shapes {
                  x, y := next.Position()
                  s.SetX(x - (next.Width() + a.space(space)))
          Severity: Major
          Found in shape/adjust.go and 1 other location - About 1 hr to fix
          shape/adjust.go on lines 76..85

          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 131.

          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 2 locations. Consider refactoring.
          Open

          func (a *Adjuster) Above(o Shape, space ...int) *Adjuster {
              next := o
              for _, s := range a.shapes {
                  x, y := next.Position()
                  s.SetY(y - (next.Height() + a.space(space)))
          Severity: Major
          Found in shape/adjust.go and 1 other location - About 1 hr to fix
          shape/adjust.go on lines 50..59

          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 131.

          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 2 locations. Consider refactoring.
          Open

          func (a *Adjuster) RightOf(o Shape, space ...int) *Adjuster {
              next := o
              for _, s := range a.shapes {
                  x, y := next.Position()
                  s.SetX(x + next.Width() + a.space(space))
          Severity: Minor
          Found in shape/adjust.go and 1 other location - About 1 hr to fix
          shape/adjust.go on lines 63..72

          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 129.

          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 2 locations. Consider refactoring.
          Open

          func (a *Adjuster) Below(o Shape, space ...int) *Adjuster {
              next := o
              for _, s := range a.shapes {
                  x, y := next.Position()
                  s.SetY(y + next.Height() + a.space(space))
          Severity: Minor
          Found in shape/adjust.go and 1 other location - About 1 hr to fix
          shape/adjust.go on lines 37..46

          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 129.

          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

          Method GanttChart.addHeader has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
          Open

          func (d *GanttChart) addHeader() []*shape.Label {
              now := d.start
              year := shape.NewLabel(fmt.Sprintf("%v", now.Year()))
              d.Diagram.Place(year).At(d.padLeft, d.padTop)
              offset := d.padLeft + d.taskWidth()
          Severity: Minor
          Found in design/ganttchart.go - About 55 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

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

          func (r *State) WriteSVG(out io.Writer) error {
              w, err := nexus.NewPrinter(out)
              w.Printf(
                  `<rect class="%s" x="%v" y="%v" width="%v" height="%v"/>`,
                  r.class, r.x, r.y, r.Width(), r.Height())
          Severity: Minor
          Found in shape/state.go and 1 other location - About 55 mins to fix
          shape/rect.go on lines 41..49

          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 123.

          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 2 locations. Consider refactoring.
          Open

          func (r *Rect) WriteSVG(out io.Writer) error {
              w, err := nexus.NewPrinter(out)
              w.Printf(
                  `<rect class="%s" x="%v" y="%v" width="%v" height="%v"/>`,
                  r.class, r.x, r.y, r.Width(), r.Height())
          Severity: Minor
          Found in shape/rect.go and 1 other location - About 55 mins to fix
          shape/state.go on lines 35..43

          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 123.

          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 2 locations. Consider refactoring.
          Open

          func (r *Rect) title() *Label {
              return &Label{
                  x:     r.x + r.Pad.Left,
                  y:     r.y + r.Pad.Top/2,
                  Font:  r.Font,
          Severity: Minor
          Found in shape/rect.go and 1 other location - About 45 mins to fix
          shape/store.go on lines 56..64

          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 113.

          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 2 locations. Consider refactoring.
          Open

          func (r *Store) title() *Label {
              return &Label{
                  x:     r.x + r.Pad.Left,
                  y:     r.y + r.Pad.Top/2,
                  Font:  r.Font,
          Severity: Minor
          Found in shape/store.go and 1 other location - About 45 mins to fix
          shape/rect.go on lines 51..59

          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 113.

          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 2 locations. Consider refactoring.
          Open

                  for _, txt := range r.Fields {
                      label := &Label{
          
                          x:     r.x + r.Pad.Left,
                          y:     r.y + y,
          Severity: Minor
          Found in shape/record.go and 1 other location - About 40 mins to fix
          shape/record.go on lines 66..77

          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 112.

          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 2 locations. Consider refactoring.
          Open

                  for _, txt := range r.Methods {
                      label := &Label{
                          x:     r.x + r.Pad.Left,
                          y:     r.y + y,
                          Font:  r.Font,
          Severity: Minor
          Found in shape/record.go and 1 other location - About 40 mins to fix
          shape/record.go on lines 47..59

          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 112.

          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 2 locations. Consider refactoring.
          Open

          func (d *Dot) WriteSVG(out io.Writer) error {
              w, err := nexus.NewPrinter(out)
              x, y := d.Position()
              x += d.Radius
              y += d.Radius
          Severity: Minor
          Found in shape/dot.go and 1 other location - About 40 mins to fix
          shape/circle.go on lines 31..41

          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 108.

          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 2 locations. Consider refactoring.
          Open

          func (c *Circle) WriteSVG(out io.Writer) error {
              w, err := nexus.NewPrinter(out)
              x, y := c.Position()
              x += c.Radius
              y += c.Radius
          Severity: Minor
          Found in shape/circle.go and 1 other location - About 40 mins to fix
          shape/dot.go on lines 34..44

          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 108.

          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

          Severity
          Category
          Status
          Source
          Language