GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [go] Error parsing unicode values · Issue #2752 · pmd/pmd

[go] Error parsing unicode values #2752

New issue
Copy link
New issue
Copy link
Closed
#3946
Closed
[go] Error parsing unicode values#2752
#3946
Copy link
Labels
a:bugPMD crashes or fails to analyse a file.in:cpdAffects the copy-paste detectorin:grammarAbout the grammar of a lexer or parser, eg, a parse/lex exception
Milestone
6.46.0

Description

@JiriSko
JiriSko
opened on Aug 28, 2020
Issue body actions

Affects PMD Version: 6.26.0

Description:

CPD crashing on following file, didn't expect that. Maybe related to #2605 ?

Exception Stacktrace:

net.sourceforge.pmd.lang.ast.TokenMgrError: Lexical error in file /tmp/goIsAmazing-master/goBasis/src/fundation/5. sliceOperation/sliceOperation6.go at line 20, column 12.  Encountered: token recognition error at: ''??'
        at net.sourceforge.pmd.cpd.AntlrTokenizer.tokenize(AntlrTokenizer.java:44)
        at net.sourceforge.pmd.cpd.CPD.addAndThrowLexicalError(CPD.java:144)
        at net.sourceforge.pmd.cpd.CPD.add(CPD.java:139)
        at net.sourceforge.pmd.cpd.CPD.add(CPD.java:108)
        at net.sourceforge.pmd.cpd.CPD.add(CPD.java:70)
        at net.sourceforge.pmd.cpd.CPD.addDirectory(CPD.java:80)
        at net.sourceforge.pmd.cpd.CPD.addRecursively(CPD.java:65)
        at net.sourceforge.pmd.cpd.CPDCommandLineInterface.addSourcesFilesToCPD(CPDCommandLineInterface.java:134)
        at net.sourceforge.pmd.cpd.CPDCommandLineInterface.addSourceFilesToCPD(CPDCommandLineInterface.java:114)
        at net.sourceforge.pmd.cpd.CPDCommandLineInterface.main(CPDCommandLineInterface.java:87)
        at net.sourceforge.pmd.cpd.CPD.main(CPD.java:179)
Caused by: LexerNoViableAltException(''')
        at org.antlr.v4.runtime.atn.LexerATNSimulator.failOrAccept(LexerATNSimulator.java:312)
        at org.antlr.v4.runtime.atn.LexerATNSimulator.execATN(LexerATNSimulator.java:233)
        at org.antlr.v4.runtime.atn.LexerATNSimulator.match(LexerATNSimulator.java:117)
        at org.antlr.v4.runtime.Lexer.nextToken(Lexer.java:141)
        at net.sourceforge.pmd.lang.go.antlr4.GolangLexer.nextToken(GolangLexer.java:126)
        at net.sourceforge.pmd.lang.antlr.AntlrTokenManager.getNextTokenFromAnyChannel(AntlrTokenManager.java:47)
        at net.sourceforge.pmd.lang.antlr.AntlrTokenManager.getNextToken(AntlrTokenManager.java:40)
        at net.sourceforge.pmd.cpd.token.internal.BaseTokenFilter.getNextToken(BaseTokenFilter.java:45)
        at net.sourceforge.pmd.cpd.AntlrTokenizer.tokenize(AntlrTokenizer.java:39)
        ... 10 more

Code Sample demonstrating the issue:

https://github.com/SuperSupeng/goIsAmazing/blob/0fef5154b97dd170144254596c46d5892454c928/goBasis/src/fundation/5.%20sliceOperation/sliceOperation6.go#L20:

package main

import "fmt"

func main() {
	//string底层是一个byte数组,因此string也可以进行切片操作
	str := "hello world"//string是不可变的
	slice := str[4:]
	fmt.Println(slice)

	//若要对string进行修改需要将string修改为byte或rune的切片在操作
	//但是转为byte无法进行中文操作
	bytes := []byte(str)
	bytes[2] = 'x'
	str = string(bytes)
	fmt.Println(str)

	//转换成rune可以对中文进行操作
	runes := []rune(str)
	runes[0] = '哈'
	str = string(runes)
	fmt.Println(str)

}

Steps to reproduce:

Clone linked repository and run cpd: ./run.sh cpd --files . --language go --minimum-tokens 50

Running PMD through: CLI

Reacted by Michal Šimon

Activity

  1. JiriSko
    added
    a:bugPMD crashes or fails to analyse a file.
    on Aug 28, 2020
  2. oowekyala
    added
    in:cpdAffects the copy-paste detector
    on Nov 11, 2020
  3. oowekyala
    added
    in:grammarAbout the grammar of a lexer or parser, eg, a parse/lex exception
    on Feb 12, 2022
  4. oowekyala
    added this to the 6.46.0 milestone on May 1, 2022
  5. oowekyala
    added a commit that references this issue on May 1, 2022

    Same for go

    This issue will close once commit 669f2fe is merged into the 'main' branch.
    669f2fe
  6. adangel
    changed the title [-][Go] Error parsing unicode values[/-] [+][go] Error parsing unicode values[/+] on May 20, 2022
  7. adangel
    added a commit that references this issue on May 26, 2022

    [doc] Update release notes (pmd#3946, pmd#3423, pmd#2605, pmd#2604, p…

    aae06c4
  8. adangel
    closed this as completedin #3946on May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:bugPMD crashes or fails to analyse a file.in:cpdAffects the copy-paste detectorin:grammarAbout the grammar of a lexer or parser, eg, a parse/lex exception

    Type

    No type

    Projects

    No projects

      Milestone

      • 6.46.0

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.