Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalArgumentException while formatting #1131

Closed
phamtrinli opened this issue Apr 9, 2018 · 2 comments
Closed

IllegalArgumentException while formatting #1131

phamtrinli opened this issue Apr 9, 2018 · 2 comments

Comments

@phamtrinli
Copy link

This template is a guideline, not a strict requirement.

  • Version: 1.4.0
  • Integration: sbt, scalafmtOnCompile in ThisBuild := true
  • Configuration:
style = IntelliJ
maxColumn = 120
align.openParenCallSite = true
align.openParenDefnSite = true
continuationIndent.defnSite = 2
danglingParentheses = false
docstrings = JavaDoc
importSelectors = singleLine
newlines.afterImplicitKWInVerticalMultiline = true
newlines.penalizeSingleSelectMultiArgList = false
rewrite.redundantBraces.stringInterpolation = true
rewrite.rules = [
  RedundantBraces,
  RedundantParens,
  PreferCurlyFors,
  SortImports
]
unindentTopLevelOperators = true
project.excludeFilters = [".*\\.sbt", "target/"]

Steps

Unfortunately sometimes an exception is thrown on code formatting (enabled on compile).

Problem

Exception occurs sometimes:

Caused by: java.lang.IllegalArgumentException: 109 is not a valid offset, allowed [0..0]
	at scala.meta.inputs.Point$Offset.<init>(Point.scala:33)
	at scala.meta.inputs.Point$Offset$.apply(Point.scala:30)
	at metaconfig.typesafeconfig.TypesafeConfig2Class$.$anonfun$getPositionOpt$6(TypesafeConfig2Class.scala:73)
	at scala.Option$WithFilter.map(Option.scala:146)
	at metaconfig.typesafeconfig.TypesafeConfig2Class$.$anonfun$getPositionOpt$2(TypesafeConfig2Class.scala:66)
	at scala.Option.flatMap(Option.scala:171)
	at metaconfig.typesafeconfig.TypesafeConfig2Class$.$anonfun$getPositionOpt$1(TypesafeConfig2Class.scala:65)
	at scala.Option.flatMap(Option.scala:171)
	at metaconfig.typesafeconfig.TypesafeConfig2Class$.getPositionOpt(TypesafeConfig2Class.scala:64)
	at metaconfig.typesafeconfig.TypesafeConfig2Class$.loop$1(TypesafeConfig2Class.scala:45)

Workaround

Usually another run of compile / format "fixes" the issue.

Notes

Using scalafmt in a play project. It seems that this exception occurs in sbt run task, maybe there is a problem with play's recompile mechanism?

@olafurpg
Copy link
Member

Thanks for reporting! The error seems related to reading the configuration file. Did you by any chance recently update the .scalafmt.conf file before this happened? If so, this is likely fixed in #1145 where we upgraded the configuration library to a version where subsequent reads from the same file are not cached.

@olafurpg
Copy link
Member

Please reopen if you are able to provide more detailed steps to reproduce

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants