Skip to content

Scalafmt introduction post work #187

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

Merged
merged 6 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ docstrings {
indent {
main = 4
callSite = 4
ctorSite = 8 # Double Indent
}
indentOperator.exemptScope = aloneEnclosed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ object ExceptionUsage extends ProjectAnalysisApplication {
}

case class ExceptionUsage(
method: Method,
definitionSite: PC,
exceptionType: String,
usageInformation: scala.collection.Set[UsageKind.Value]
method: Method,
definitionSite: PC,
exceptionType: String,
usageInformation: scala.collection.Set[UsageKind.Value]
) extends scala.math.Ordered[ExceptionUsage] {

override def toString: String = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import scala.collection.parallel.CollectionConverters.IterableIsParallelizable
object MethodReturnValuesAnalysis extends ProjectAnalysisApplication {

class AnalysisDomain(
override val project: Project[java.net.URL],
val ai: InterruptableAI[_],
val method: Method
override val project: Project[java.net.URL],
val ai: InterruptableAI[_],
val method: Method
) extends CorrelationalDomain
with domain.DefaultSpecialDomainValuesBinding
with domain.ThrowAllPotentialExceptionsConfiguration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ object IdentifyResourcesAnalysis extends ProjectAnalysisApplication {
// Perform a simple abstract interpretation to check if there is some
// method that passes a constant string to a method.
class AnalysisDomain(
override val project: Project[URL],
val method: Method
override val project: Project[URL],
val method: Method
) extends CorrelationalDomain
with domain.TheProject
with domain.TheMethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import scala.collection.parallel.CollectionConverters.IterableIsParallelizable
object IdentifyResourcesAnalysis extends ProjectAnalysisApplication {

class AnalysisDomain(
override val project: Project[URL],
val method: Method
override val project: Project[URL],
val method: Method
) extends CorrelationalDomain
with domain.DefaultSpecialDomainValuesBinding
with domain.ThrowAllPotentialExceptionsConfiguration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import org.opalj.collection.mutable.IntArrayStack
import org.opalj.io.writeAndOpen

case class FlowEntity(
pc: Int,
instruction: Instruction,
operands: Operands[_ >: Null <: Domain#DomainValue],
locals: Locals[_ >: Null <: Domain#DomainValue],
properties: Option[String]
pc: Int,
instruction: Instruction,
operands: Operands[_ >: Null <: Domain#DomainValue],
locals: Locals[_ >: Null <: Domain#DomainValue],
properties: Option[String]
) {
val flowId = FlowEntity.nextFlowId
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ abstract class PropertiesTest extends AnyFunSpec with Matchers {
}

case class TestContext(
project: Project[URL],
propertyStore: PropertyStore,
analyses: List[FPCFAnalysis]
project: Project[URL],
propertyStore: PropertyStore,
analyses: List[FPCFAnalysis]
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import org.opalj.br.fpcf.properties.AllocationFreeness
* @author Dominik Helm
*/
sealed abstract class AllocationFreenessMatcher(
val property: AllocationFreeness
val property: AllocationFreeness
) extends AbstractPropertyMatcher {

def validateProperty(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import org.opalj.br.fpcf.properties.CompileTimeVaryingField
* @author Dominik Helm
*/
sealed abstract class CompileTimeConstancyMatcher(
val property: CompileTimeConstancy
val property: CompileTimeConstancy
) extends AbstractPropertyMatcher {

def validateProperty(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import org.opalj.tac.common.DefinitionSite
* @author Florian Kuebler
*/
abstract class EscapePropertyMatcher(
val property: EscapeProperty
val property: EscapeProperty
) extends AbstractPropertyMatcher {

override def isRelevant(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import org.opalj.fpcf.Property
import org.opalj.fpcf.properties.AbstractPropertyMatcher

class TypeImmutabilityMatcher(
val property: TypeImmutability
val property: TypeImmutability
) extends AbstractPropertyMatcher {

import org.opalj.br.analyses.SomeProject
Expand Down
671 changes: 380 additions & 291 deletions Eclipse Java Formatter Preferences.xml

Large diffs are not rendered by default.

80 changes: 52 additions & 28 deletions IntelliJ Java and Scala Formatter Preferences.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<code_scheme name="Java Conventions [maximum line width 100]" version="173">
<option name="RIGHT_MARGIN" value="100" />
<code_scheme name="Project" version="173">
<option name="RIGHT_MARGIN" value="120" />
<option name="FORMATTER_TAGS_ENABLED" value="true" />
<option name="SOFT_MARGINS" value="120" />
<JavaCodeStyleSettings>
<option name="ANNOTATION_PARAMETER_WRAP" value="1" />
</JavaCodeStyleSettings>
<ScalaCodeStyleSettings>
<option name="classCountToUseImportOnDemand" value="32" />
<option name="classCountToUseImportOnDemand" value="60" />
<option name="collectImports" value="false" />
<option name="doNotChangeLocalImportsOnOptimize" value="false" />
<option name="importLayout">
Expand All @@ -15,27 +16,19 @@
<option value="scala.reflect" />
<option value="_______ blank line _______" />
<option value="java" />
<option value="_______ blank line _______" />
<option value="scala" />
<option value="play" />
<option value="_______ blank line _______" />
<option value="all other imports" />
<option value="org.junit" />
<option value="org.scalacheck" />
<option value="org.scalatest" />
<option value="org.scalatestplus" />
<option value="_______ blank line _______" />
<option value="com.typesafe.config" />
<option value="_______ blank line _______" />
<option value="org.opalj" />
<option value="_______ blank line _______" />
<option value="org.opalj.log" />
<option value="org.opalj.util" />
<option value="org.opalj.collection" />
<option value="org.opalj.concurrent" />
<option value="org.opalj.fpcf" />
<option value="org.opalj.bytecode" />
<option value="org.opalj.value" />
<option value="org.opalj.bi" />
<option value="org.opalj.da" />
<option value="org.opalj.br" />
<option value="org.opalj.bc" />
<option value="org.opalj.ba" />
<option value="org.opalj.ai" />
<option value="org.opalj.tac" />
<option value="org.opalj.de" />
<option value="org.opalj.av" />
<option value="all other imports" />
</array>
</option>
<option name="importShortestPathForAmbiguousReferences" value="false" />
Expand Down Expand Up @@ -87,18 +80,35 @@
<option value="scala.reflect.macros.whitebox.Context" />
</array>
</option>
<option name="sortAsScalastyle" value="true" />
<option name="USE_SCALADOC2_FORMATTING" value="false" />
<option name="WRAP_BEFORE_WITH_KEYWORD" value="true" />
<option name="PLACE_SELF_TYPE_ON_NEW_LINE" value="false" />
<option name="ALIGN_EXTENDS_WITH" value="3" />
<option name="ALIGN_IN_COLUMNS_CASE_BRANCH" value="true" />
<option name="ALIGN_COMPOSITE_PATTERN" value="false" />
<option name="INDENT_FIRST_PARAMETER" value="false" />
<option name="SCALAFMT_CONFIG_PATH" value="/home/dominik/Work/opal/.scalafmt.conf" />
<option name="SCALAFMT_REFORMAT_ON_FILES_SAVE" value="true" />
<option name="FORMATTER" value="1" />
<option name="SPACE_AFTER_MODIFIERS_CONSTRUCTOR" value="true" />
<option name="SPACES_IN_ONE_LINE_BLOCKS" value="true" />
<option name="SPACES_AROUND_AT_IN_PATTERNS" value="true" />
<option name="ALIGN_PARAMETER_TYPES_IN_MULTILINE_DECLARATIONS" value="2" />
<option name="SPACE_BEFORE_TYPE_PARAMETER_LEADING_CONTEXT_BOUND_COLON_HK" value="false" />
<option name="CALL_PARAMETERS_NEW_LINE_AFTER_LPAREN" value="2" />
<option name="MULTILINE_STRING_ALIGN_DANGLING_CLOSING_QUOTES" value="true" />
<option name="TYPE_ANNOTATION_EXCLUDE_MEMBER_OF_ANONYMOUS_CLASS" value="true" />
<option name="TYPE_ANNOTATION_EXCLUDE_MEMBER_OF_PRIVATE_CLASS" value="true" />
<option name="SD_BLANK_LINE_AFTER_PARAMETERS_COMMENTS" value="true" />
<option name="SD_BLANK_LINE_AFTER_RETURN_COMMENTS" value="true" />
<option name="SD_BLANK_LINE_BEFORE_PARAMETERS" value="true" />
<option name="SD_KEEP_BLANK_LINES_BETWEEN_TAGS" value="true" />
<option name="SD_PRESERVE_SPACES_IN_TAGS" value="true" />
<!-- Unicode arrows are not supported anymore since Scala 2.13 -->
<option name="REPLACE_CASE_ARROW_WITH_UNICODE_CHAR" value="false" />
<option name="REPLACE_MAP_ARROW_WITH_UNICODE_CHAR" value="false" />
<option name="REPLACE_FOR_GENERATOR_ARROW_WITH_UNICODE_CHAR" value="false" />
<option name="TRAILING_COMMA_MODE" value="TRAILING_COMMA_REMOVE_WHEN_MULTILINE" />
<option name="TRAILING_COMMA_TUPLE_ENABLED" value="true" />
<option name="TRAILING_COMMA_TUPLE_TYPE_ENABLED" value="true" />
<option name="TRAILING_COMMA_PATTERN_ARG_LIST_ENABLED" value="true" />
<option name="TRAILING_COMMA_TYPE_PARAMS_ENABLED" value="true" />
<option name="TRAILING_COMMA_IMPORT_SELECTOR_ENABLED" value="true" />
</ScalaCodeStyleSettings>
<codeStyleSettings language="JAVA">
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
Expand Down Expand Up @@ -138,7 +148,21 @@
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="Scala">
<option name="MODIFIER_LIST_WRAP" value="true" />
<option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
<option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" />
<option name="CALL_PARAMETERS_WRAP" value="5" />
<option name="CALL_PARAMETERS_RPAREN_ON_NEXT_LINE" value="true" />
<option name="METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
<option name="METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE" value="true" />
<option name="EXTENDS_LIST_WRAP" value="5" />
<option name="EXTENDS_KEYWORD_WRAP" value="1" />
<option name="METHOD_CALL_CHAIN_WRAP" value="1" />
<option name="BINARY_OPERATION_WRAP" value="1" />
<option name="FOR_STATEMENT_WRAP" value="2" />
<option name="VARIABLE_ANNOTATION_WRAP" value="2" />
<option name="SOFT_MARGINS" value="120" />
<indentOptions>
<option name="INDENT_SIZE" value="4" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class RecordDefUseTest extends AnyFunSpec with Matchers {
protected[this] object DominatorsPerformanceEvaluation extends PerformanceEvaluation

protected[this] class DefUseDomain(
val method: Method,
val project: Project[URL]
val method: Method,
val project: Project[URL]
) extends CorrelationalDomain
with TheProject
with TheMethod
Expand All @@ -57,8 +57,8 @@ class RecordDefUseTest extends AnyFunSpec with Matchers {
with RecordDefUse // <=== we are going to test!

protected[this] class RefinedDefUseDomain(
method: Method,
project: Project[URL]
method: Method,
project: Project[URL]
) extends DefUseDomain(method, project)
with RefineDefUseUsingOrigins // this should not really affect the results...

Expand Down
4 changes: 2 additions & 2 deletions OPAL/ai/src/main/scala/org/opalj/ai/AI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ import org.opalj.log.Warn
* @author Michael Eichberg
*/
abstract class AI[D <: Domain](
final val IdentifyDeadVariables: Boolean = true,
final val RegisterStoreMayThrowExceptions: Boolean = false
final val IdentifyDeadVariables: Boolean = true,
final val RegisterStoreMayThrowExceptions: Boolean = false
) {

type SomeLocals[V <: d.DomainValue forSome { val d: D }] = Option[IndexedSeq[V]]
Expand Down
8 changes: 4 additions & 4 deletions OPAL/ai/src/main/scala/org/opalj/ai/AIException.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ package ai
* @author Michael Eichberg
*/
class AIException(
message: String = null,
cause: Throwable = null,
enableSuppression: Boolean = false,
writableStackTrace: Boolean = true
message: String = null,
cause: Throwable = null,
enableSuppression: Boolean = false,
writableStackTrace: Boolean = true
) extends RuntimeException(message, cause, enableSuppression, writableStackTrace)
4 changes: 2 additions & 2 deletions OPAL/ai/src/main/scala/org/opalj/ai/BaseAI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ package ai
* @author Michael Eichberg
*/
class BaseAI(
IdentifyDeadVariables: Boolean = true,
RegisterStoreMayThrowExceptions: Boolean = false
IdentifyDeadVariables: Boolean = true,
RegisterStoreMayThrowExceptions: Boolean = false
) extends AI[Domain](IdentifyDeadVariables, RegisterStoreMayThrowExceptions) {

override def isInterrupted: Boolean = Thread.interrupted()
Expand Down
20 changes: 10 additions & 10 deletions OPAL/ai/src/main/scala/org/opalj/ai/BoundedInterruptableAI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ import org.opalj.util.Nanoseconds
* @author Michael Eichberg
*/
class BoundedInterruptableAI[D <: Domain](
maxEvaluationCount: Int,
val maxEvaluationTime: Nanoseconds,
val doInterrupt: () => Boolean,
IdentifyDeadVariables: Boolean
maxEvaluationCount: Int,
val maxEvaluationTime: Nanoseconds,
val doInterrupt: () => Boolean,
IdentifyDeadVariables: Boolean
) extends InstructionCountBoundedAI[D](maxEvaluationCount, IdentifyDeadVariables) {

private[this] var startTime: Long = -1L;

def this(
code: Code,
maxEvaluationFactor: Double,
maxEvaluationTime: Milliseconds,
doInterrupt: () => Boolean,
identifyDeadVariables: Boolean = true
code: Code,
maxEvaluationFactor: Double,
maxEvaluationTime: Milliseconds,
doInterrupt: () => Boolean,
identifyDeadVariables: Boolean = true
)(
implicit logContext: LogContext
implicit logContext: LogContext
) = {
this(
InstructionCountBoundedAI.calculateMaxEvaluationCount(code, maxEvaluationFactor),
Expand Down
6 changes: 3 additions & 3 deletions OPAL/ai/src/main/scala/org/opalj/ai/Computation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ final case class ComputedValue[+V](result: V) extends Computation[V, Nothing] {
* or threw an exception.
*/
final case class ComputedValueOrException[+V, +E](
result: V,
exceptions: E
result: V,
exceptions: E
) extends Computation[V, E] {

def returnsNormally: Boolean = true
Expand Down Expand Up @@ -169,7 +169,7 @@ final case class ThrowsException[+E](exceptions: E) extends Computation[Nothing,
* did not return some value) or that threw an exception/multiple exceptions.
*/
final case class ComputationWithSideEffectOrException[+E](
exceptions: E
exceptions: E
) extends Computation[Nothing, E] {

def returnsNormally: Boolean = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ import org.opalj.log.OPALLogger
* @author Michael Eichberg
*/
class InstructionCountBoundedAI[D <: Domain](
val maxEvaluationCount: Int,
IdentifyDeadVariables: Boolean
val maxEvaluationCount: Int,
IdentifyDeadVariables: Boolean
) extends AI[D](IdentifyDeadVariables) {

/**
* @param maxEvaluationFactor Determines the maximum number of instruction evaluations
* before the evaluation of the method is automatically interrupted.
*/
def this(
code: Code,
maxEvaluationFactor: Double = 1.5d,
identifyDeadVariables: Boolean = true
code: Code,
maxEvaluationFactor: Double = 1.5d,
identifyDeadVariables: Boolean = true
)(implicit logContext: LogContext) = {
this(
InstructionCountBoundedAI.calculateMaxEvaluationCount(code, maxEvaluationFactor),
Expand Down
2 changes: 1 addition & 1 deletion OPAL/ai/src/main/scala/org/opalj/ai/TimeBoundedAI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import org.opalj.util.Nanoseconds
* @author Michael Eichberg
*/
class TimeBoundedAI[D <: Domain](
val maxEffort: Nanoseconds = new Milliseconds(150L).toNanoseconds
val maxEffort: Nanoseconds = new Milliseconds(150L).toNanoseconds
) extends AI[D] {

private[this] final val CheckInterval = 100
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import org.opalj.br.analyses.SomeProject
object DomainRegistry {

case class DomainMetaInformation(
lessPreciseDomains: Set[Class[_ <: Domain]],
factory: (SomeProject, Method) => Domain
lessPreciseDomains: Set[Class[_ <: Domain]],
factory: (SomeProject, Method) => Domain
)

type ClassRegistry = Map[Class[_ <: Domain], DomainMetaInformation]
Expand Down
Loading