Code Monkey home page Code Monkey logo

Comments (6)

yoheimuta avatar yoheimuta commented on May 22, 2024 1

@bochengyang We already have a disable comment feature. So you can append // protolint:disable:this MAX_LINE_LENGTH at the end of the target line to skip the check.

from protolint.

yoheimuta avatar yoheimuta commented on May 22, 2024

@sulume Thank you for your feature request!
It makes sense a lot overall. I understand the need to accept some exceptions.

Do you have any good ideas or references to a specific implementation for that?
I think protolint should conservatively handle the exceptions because it already allows end-users to disable the rule by a line.

At first glance, at least an exception for import paths would be right without any nasty surprises.

[memo] Here is a current implementation.

  • func(index int, line string) {
    line = strings.Replace(line, "\t", strings.Repeat(" ", r.tabChars), -1)
    lineCount := utf8.RuneCountInString(line)
    if r.maxChars < lineCount {
    failures = append(failures, report.Failuref(
    meta.Position{
    Filename: fileName,
    Line: index + 1,
    Column: 1,
    },
    r.ID(),
    "The line length is %d, but it must be shorter than %d",
    lineCount,
    r.maxChars,
    ))
    }
    },

from protolint.

sulume avatar sulume commented on May 22, 2024

Thank you for your quick response.

I think protolint should conservatively handle the exceptions because it already allows end-users to disable the rule by a line.

I'm not really sure how the consistency is maintained, but I think one way is to add another rule option alongside max_chars and tab_chars so that users have options on its behavior and existing users would see it working the same by default.

For example,

  • a boolean rule option to ignore import lines, and another for URLs
    • Separate options may have different default values.
    • There would be no single general criteria to decide if a line of URL is not splittable, so it might need a heuristic rule, e.g. a comment line with only a single URL.
  • a string rule option to specify a regexp pattern to match lines to ignore their lengths
    • This way leaves users some extensibility for arbitrary long ID strings.

from protolint.

yoheimuta avatar yoheimuta commented on May 22, 2024

@sulume

so that users have options on its behavior and existing users would see it working the same by default.

That sounds great. Thank you for providing nice examples.
Thanks to those, it's time to implement each exception incrementally.

[memo] I'm thinking of working on them when I finish existing priority issues.
If you need them (asap) before I will assign myself, PRs are always welcome.

from protolint.

bochengyang avatar bochengyang commented on May 22, 2024

@yoheimuta

Since we can extract each line individually, can we have a regex for extracting annotation, e.g., #protolint:ignore: MAX_LINE_LENGTH at the end of the original protobuf definition? Once a rule is specified to be ignored, the line length is not a problem.

from protolint.

bochengyang avatar bochengyang commented on May 22, 2024

Great! It saves my day :)

Thanks

from protolint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.