j-mie6/parsley

View on GitHub

Showing 71 of 231 total issues

Function render has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Confirmed

        private def render(selfTimes: Map[String, Long], invocations: Map[String, Int]): Unit = {
            val combined = selfTimes.map {
                case (name, selfTime) =>
                    val invokes = invocations(name)
                    (name, (f"${selfTime/1000.0}%.1fμs", invocations(name), f"${selfTime/invokes/1000.0}%.3fμs"))
Severity: Minor
Found in parsley/shared/src/main/scala/parsley/debug.scala - About 1 hr to fix

    Function process has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Confirmed

            private [parsley] def process: (Map[String, Long], Map[String, Int]) = {
                val allEntries = collapse(entries).sortBy(_._2)
                val allExits = collapse(exits).sortBy(_._2)
    
                require((allEntries ::: allExits).toSet.size == (allExits.length + allExits.length),
    Severity: Minor
    Found in parsley/shared/src/main/scala/parsley/debug.scala - About 1 hr to fix

      Method foldTablified has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          @tailrec private def foldTablified(tablified: List[(StrictParsley[_], (Char, Iterable[ExpectItem], Int, Boolean))], // scalastyle:ignore parameter.number
                                             labelGen: CodeGenState,
                                             roots: mutable.Map[Char, mutable.ListBuffer[StrictParsley[_]]],
                                             backtracking: mutable.Map[Char, Boolean],
                                             leads: mutable.ListBuffer[Char],

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

            private [machine] final override def dislodge(by: Int): FancyDefuncError = this match {
                case self: FancyEntrenched if by == self.by => self.err
                case self if !self.entrenched => self
                case self: FancyDislodged => new FancyDislodged(self.by + by, self.err)
                case self => new FancyDislodged(by, self)
        parsley/shared/src/main/scala/parsley/internal/machine/errors/DefuncError.scala on lines 213..218

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

        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

            private [machine] final override def dislodge(by: Int): TrivialDefuncError = this match {
                case self: TrivialEntrenched if by == self.by => self.err
                case self if !self.entrenched => self
                case self: TrivialDislodged => new TrivialDislodged(self.by + by, self.err)
                case self => new TrivialDislodged(by, self)
        parsley/shared/src/main/scala/parsley/internal/machine/errors/DefuncError.scala on lines 261..266

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

        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 readSpecific has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            final private def readSpecific(ctx: Context, j: Int): Unit = {
                if (j < strsz) {
                    val c = specific.codePointAt(j)
                    if (Character.isSupplementaryCodePoint(c) && ctx.moreInput(2) && readCharCaseHandledSupplementary(ctx) == c) {
                        ctx.fastConsumeSupplementaryChar()

        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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Confirmed

                    assume(handler.stacksz == ctx.stack.usize && handler.check == ctx.offset
                        && handler.hints == ctx.hints && handler.hintOffset == ctx.currentHintsValidOffset,
                        "the handler can be re-used")
        parsley/shared/src/main/scala/parsley/internal/machine/instructions/CoreInstrs.scala on lines 271..273

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

        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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Confirmed

                assume(handler.stacksz == ctx.stack.usize && handler.check == ctx.offset
                    && handler.hints == ctx.hints && handler.hintOffset == ctx.currentHintsValidOffset,
                       "the handler can be re-used")
        parsley/shared/src/main/scala/parsley/internal/machine/instructions/CoreInstrs.scala on lines 252..254

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

        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

            def isDouble(n: BigDecimal): Boolean = {
                n == 0.0 || n == -0.0 || {
                    val x = n.toDouble
                    !x.isInfinity && x != 0.0 && x != -0.0
                }
        parsley/shared/src/main/scala/parsley/token/numeric/Real.scala on lines 334..339

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

        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

            def isFloat(n: BigDecimal): Boolean = {
                n == 0.0 || n == -0.0 || {
                    val x = n.toFloat
                    !x.isInfinity && x != 0.0 && x != -0.0
                }
        parsley/shared/src/main/scala/parsley/token/numeric/Real.scala on lines 327..332

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

        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 merge has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            private [machine] final override def merge(err: DefuncError): DefuncError = {
                val cmp = Integer.compareUnsigned(this.underlyingOffset, err.underlyingOffset)
                if (cmp > 0) this
                else if (cmp < 0) err
                else {

        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 merge has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            private [machine] final override def merge(err: DefuncError): DefuncError = {
                val cmp = Integer.compareUnsigned(this.underlyingOffset, err.underlyingOffset)
                if (cmp > 0) this
                else if (cmp < 0) err
                else {

        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 process has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Confirmed

                private [parsley] def process: (Map[String, Long], Map[String, Int]) = {
                    val allEntries = collapse(entries).sortBy(_._2)
                    val allExits = collapse(exits).sortBy(_._2)
        
                    require((allEntries ::: allExits).toSet.size == (allExits.length + allExits.length),
        Severity: Minor
        Found in parsley/shared/src/main/scala/parsley/debug.scala - 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

        Constructor has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            inp: Input,
            fof: Offset,
            tof: Offset,
            fps: Pos,
            tps: Pos,
        Severity: Major
        Found in parsley-debug/shared/src/main/scala/parsley/debugger/ParseAttempt.scala - About 50 mins to fix

          Method copy has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  inp: Input = rawInput,
                  fof: Offset = fromOffset,
                  tof: Offset = toOffset,
                  fps: Pos = fromPos,
                  tps: Pos = toPos,
          Severity: Major
          Found in parsley-debug/shared/src/main/scala/parsley/debugger/ParseAttempt.scala - About 50 mins to fix

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

                    suspend(p.codeGen[M, R](producesResults)) |> {
                        instrs += new instructions.Label(handler)
                        instrs += (if (producesResults) new instructions.Many(body) else new instructions.SkipMany(body))
                    }
            parsley/shared/src/main/scala/parsley/internal/deepembedding/backend/IterativeEmbedding.scala on lines 61..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 81.

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

                        suspend(op.codeGen[M, R](producesResults)) |> {
                            instrs += new instructions.Label(handler)
                            instrs += (if (producesResults) new instructions.ChainPost(body) else new instructions.SkipMany(body))
                        }
            parsley/shared/src/main/scala/parsley/internal/deepembedding/backend/IterativeEmbedding.scala on lines 30..33

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

            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

                def prependOne(x: A): this.type = {
                    val start = new Node(x, this.start, null)
                    this.start = start
                    if (this.end == null) this.end = this.start
                    this
            parsley/shared/src/main/scala/parsley/internal/collection/mutable/SinglyLinkedList.scala on lines 48..53

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

            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 wellNested has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                @tailrec private final def wellNested(ctx: Context, unmatched: Int): Boolean = {
                    if (unmatched == 0) true
                    else if (ctx.input.startsWith(end, ctx.offset)) {
                        ctx.fastUncheckedConsumeChars(end.length)
                        wellNested(ctx, unmatched - 1)

            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

            Constructor has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                var name: String = "",
                var internal: String = "",
                fullInput: String,
                var parse: Option[ParseAttempt] = None,
                var cNumber: Option[Long] = None,
              Severity
              Category
              Status
              Source
              Language