Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
formatting fixes for YARP
Following issues are addressed:

---
"constant misnomer (has: AssocSplat, should have: AssocSplatNode) brings on formatting failure": "{a => b}"
hash label key duplicated: "{a: b}"
identity hash formatting failure: "{a:}"
mixed hash content loss: "{a => b, c: d}"
funcall with kwargs gets bogus '=>': "fun(a: b)"
"empty #call formatting failure": fun[]
"#-@ appended to arg": "-1"
empty funcall formatting failure: fun()
empty super call formatting failure: super()
ternary conditional formatting failure: "a ? b : c"
incorrect postfix unless for compound statements: unless a; b; c; end
AlternationPatternNode: foo => bar | baz
CallOperatorAndWriteNode: foo.bar &&= value
CallOperatorOrWriteNode: foo.bar ||= value
ClassVariableOperatorAndWriteNode: "@@target &&= value"
ClassVariableOperatorOrWriteNode: "@@target ||= value"
ClassVariableOperatorWriteNode: "@@target += value"
ConstantOperatorAndWriteNode: Target &&= value
ConstantOperatorOrWriteNode: Target ||= value
ConstantOperatorWriteNode: Target += value
ConstantPathOperatorWriteNode: Parent::Child += value
ConstantPathOperatorAndWriteNode: Parent::Child &&= value
ConstantPathOperatorOrWriteNode: Parent::Child ||= value
GlobalVariableOperatorAndWriteNode: $target &&= value
GlobalVariableOperatorOrWriteNode: $target ||= value
GlobalVariableOperatorWriteNode: $target += value
InstanceVariableOperatorAndWriteNode: "@target &&= value"
InstanceVariableOperatorOrWriteNode: "@target ||= value"
InstanceVariableOperatorWriteNode: "@target += value"
KeywordHashNode: "[**{}]"
LocalVariableOperatorAndWriteNode: target &&= value
LocalVariableOperatorOrWriteNode: target ||= value
OrNode: left or right
RequiredDestructuredParameterNode: def foo((bar, baz)); end
SourceFileNode: __FILE__
SourceLineNode: __LINE__
SourceEncodingNode: __ENCODING__

Notes:

- Entries associated with a YARP Node class indicate a formatting
  failure due to #format method not being implemented for given
  class; so in these cases the fix boils down to implementing format.
- For these entries the sample code that's given in the entry is the
  sample code from the YARP definition (config.yml), with one exception:
  the sample code for KeywordHashNode is 'foo(a: b)', but for that
  expression the formatting code preempts winding down to the
  KeywordHashNode instance, so the lack of KeywordHashNode#format is
  not triggered. The expression given for KeywordHashNode does indeed
  trigger KeywordHashNode#format. (Ironically, 'foo(a: b)' still had
  a formatting issue, but for a different reason.)
- The aforementioned class tagged entries and the ones where
  "formatting failure" is indicated raise an exception with
  SyntaxTree::Formatter.format; the other cases do return but with a
  bogus result.
- The hash related issues (ones where the word 'hash' occurs in the label,
  entries 2. to 4.) are shadowed by the first one (constant misnomer).
  Without fixing the name these entries will also end up with an exception.
  When the constant name is fixed, the indicated issue will be present.

Tested with YARP 0eb5f7c3.
  • Loading branch information
csabahenk committed Jul 9, 2023
commit 6b6d3375e6c9448c38e92265eeb296d755d263b2
Loading