Skip to content

Conversation

@jackfirth
Copy link
Owner

No description provided.

@jackfirth jackfirth force-pushed the action-v2-testing branch 18 times, most recently from 7fef5ec to bb2a00d Compare June 25, 2022 07:22
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resyntax analyzed 1 file in this pull request and has added suggestions.

@jackfirth jackfirth force-pushed the action-v2-testing branch from 1aef0fd to a3341f2 Compare June 25, 2022 23:59
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resyntax analyzed 1 file in this pull request and has added suggestions.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resyntax analyzed 1 file in this pull request and has added suggestions.

Comment on lines +4 to +7
(define (distance x1 y1 x2 y2)
(let ([dx (- x1 x2)]
[dy (- y1 y2)])
(sqrt (+ (* dx dx) (* dy dy)))))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let-to-define Internal definitions are recommended instead of let expressions, to reduce nesting.

Suggested change
(define (distance x1 y1 x2 y2)
(let ([dx (- x1 x2)]
[dy (- y1 y2)])
(sqrt (+ (* dx dx) (* dy dy)))))
(define (distance x1 y1 x2 y2)
(define dx (- x1 x2))
(define dy (- y1 y2))
(sqrt (+ (* dx dx) (* dy dy))))

Debugging details below:

Textual replacement
(line-replacement
  #:new-lines
    '#("(define (distance x1 y1 x2 y2)"
       "  (define dx (- x1 x2))"
       "  (define dy (- y1 y2))"
       "  (sqrt (+ (* dx dx) (* dy dy))))")
  #:original-lines
    '#("(define (distance x1 y1 x2 y2)"
       "  (let ([dx (- x1 x2)]"
       "        [dy (- y1 y2)])"
       "    (sqrt (+ (* dx dx) (* dy dy)))))")
  #:start-line 4)
Syntactic replacement
(syntax-replacement
  #:new-syntax
    #<syntax:/home/runner/.local/share/racket/8.5/pkgs/resyntax/default-recommendations/let-binding-suggestions.rkt:44:3 (define (distance x1 y1 x2 y2) NEWLINE (define dx (- x1 x2)) NEWLINE (define dy (- y1 y2)) NEWLINE (sqrt (+ (* dx dx) (* dy dy))))>
  #:original-syntax
    #<syntax:test.rkt:4:0 (define (distance x1 y1 x2 y2) (let ((dx (- x1 x2)) (dy (- y1 y2))) (sqrt (+ (* dx dx) (* dy dy)))))>)

(sqrt (+ (* dx dx) (* dy dy)))))


(or 1 (or 2 3))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nested-or-to-flat-or Nested or expressions can be flattened to a single, equivalent or expression.

Suggested change
(or 1 (or 2 3))
(or 1 2 3)

Debugging details below:

Textual replacement
(line-replacement
  #:new-lines '#("(or 1 2 3)")
  #:original-lines '#("(or 1 (or 2 3))")
  #:start-line 10)
Syntactic replacement
(syntax-replacement
  #:new-syntax
    #<syntax:/home/runner/.local/share/racket/8.5/pkgs/resyntax/default-recommendations/boolean-shortcuts.rkt:34:3 (or 1 2 3)>
  #:original-syntax #<syntax:test.rkt:10:0 (or 1 (or 2 3))>)

(or 1 (or 2 3))


(if 'cond 'then (if 'cond2 'then2 'else))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nested-if-to-cond This if-else chain can be converted to a cond expression.

Suggested change
(if 'cond 'then (if 'cond2 'then2 'else))
(cond
['cond 'then]
['cond2 'then2]
[else 'else])

Debugging details below:

Textual replacement
(line-replacement
  #:new-lines
    '#("(cond" "  ['cond 'then]" "  ['cond2 'then2]" "  [else 'else])")
  #:original-lines '#("(if 'cond 'then (if 'cond2 'then2 'else))")
  #:start-line 13)
Syntactic replacement
(syntax-replacement
  #:new-syntax
    #<syntax:/home/runner/.local/share/racket/8.5/pkgs/resyntax/default-recommendations/conditional-shortcuts.rkt:45:3 (cond NEWLINE ((quote cond) (quote then)) NEWLINE ((quote cond2) (quote then2)) NEWLINE (else (quote else)))>
  #:original-syntax
    #<syntax:test.rkt:13:0 (if (quote cond) (quote then) (if (quote cond2) (quote then2) (quote else)))>)

Comment on lines +16 to +18
(if 'a
(println "true branch")
#f)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if-else-false-to-and This if expression can be refactored to an equivalent expression using and.

Suggested change
(if 'a
(println "true branch")
#f)
(and 'a
(println "true branch"))

Debugging details below:

Textual replacement
(line-replacement
  #:new-lines '#("(and 'a" "     (println \"true branch\"))")
  #:original-lines '#("(if 'a" "    (println \"true branch\")" "    #f)")
  #:start-line 16)
Syntactic replacement
(syntax-replacement
  #:new-syntax
    #<syntax:/home/runner/.local/share/racket/8.5/pkgs/resyntax/default-recommendations/boolean-shortcuts.rkt:84:3 (and (ORIGINAL-SPLICE (quote a) (println "true branch")))>
  #:original-syntax
    #<syntax:test.rkt:16:0 (if (quote a) (println "true branch") #f)>)

Comment on lines +22 to +26
(for-each
(λ (x)
(displayln x)
(displayln x))
some-list)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for-each-to-for This for-each operation can be replaced with a for loop.

Suggested change
(for-each
(λ (x)
(displayln x)
(displayln x))
some-list)
(for ([x (in-list some-list)])
(displayln x)
(displayln x))

Debugging details below:

Textual replacement
(line-replacement
  #:new-lines
    '#("(for ([x (in-list some-list)])" "  (displayln x)" "  (displayln x))")
  #:original-lines
    '#("(for-each"
       " (λ (x)"
       "   (displayln x)"
       "   (displayln x))"
       " some-list)")
  #:start-line 22)
Syntactic replacement
(syntax-replacement
  #:new-syntax
    #<syntax:/home/runner/.local/share/racket/8.5/pkgs/resyntax/default-recommendations/for-loop-shortcuts.rkt:149:3 (for ((x (in-list some-list))) NEWLINE (ORIGINAL-SPLICE (displayln x) (displayln x)))>
  #:original-syntax
    #<syntax:test.rkt:22:0 (for-each (λ (x) (displayln x) (displayln x)) some-list)>)

Comment on lines +30 to +36
(ormap
(λ (x)
(and (number? x)
(positive? x)
(even? x)
(< x 10)))
some-list2)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ormap-to-for/or This ormap operation can be replaced with a for/or loop.

Suggested change
(ormap
(λ (x)
(and (number? x)
(positive? x)
(even? x)
(< x 10)))
some-list2)
(for/or ([x (in-list some-list2)])
(and (number? x)
(positive? x)
(even? x)
(< x 10)))

Debugging details below:

Textual replacement
(line-replacement
  #:new-lines
    '#("(for/or ([x (in-list some-list2)])"
       "  (and (number? x)"
       "       (positive? x)"
       "       (even? x)"
       "       (< x 10)))")
  #:original-lines
    '#("(ormap"
       " (λ (x)"
       "   (and (number? x)"
       "        (positive? x)"
       "        (even? x)"
       "        (< x 10)))"
       " some-list2)")
  #:start-line 30)
Syntactic replacement
(syntax-replacement
  #:new-syntax
    #<syntax:/home/runner/.local/share/racket/8.5/pkgs/resyntax/default-recommendations/for-loop-shortcuts.rkt:158:3 (for/or ((x (in-list some-list2))) NEWLINE (and (number? x) (positive? x) (even? x) (< x 10)))>
  #:original-syntax
    #<syntax:test.rkt:30:0 (ormap (λ (x) (and (number? x) (positive? x) (even? x) (< x 10))) some-list2)>)

Copy link
Owner Author

@jackfirth jackfirth Jun 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sorawee fixed 😄

jackfirth added a commit to jackfirth/typed-racket that referenced this pull request Jun 26, 2022
@samth expressed interest in setting up [Resyntax](https://docs.racket-lang.org/resyntax/) in the Typed Racket repository. This CL adds a github workflow which runs Resyntax on any changed files in a pull request. Resyntax will suggest changes in the form of a github review, [like this](jackfirth/racket-package-resyntax-action#9 (review)). To apply the changes, the pull request author simply need click the "Commit suggestion" button that shows up in each comment. Suggestions can also be ignored freely; the review does not block merges.

The tool and the github integration are both still in the early phases so there are probably several bugs to work out here. If a suggestion looks wonky, @-mention me and I'll take a look at it.
jackfirth added a commit to jackfirth/typed-racket that referenced this pull request Jun 26, 2022
Analyze pull requests with Resyntax

@samth expressed interest in setting up [Resyntax](https://docs.racket-lang.org/resyntax/) in the Typed Racket repository. This CL adds a github workflow which runs Resyntax on any changed files in a pull request. Resyntax will suggest changes in the form of a github review, [like this](jackfirth/racket-package-resyntax-action#9 (review)). To apply the changes, the pull request author simply need click the "Commit suggestion" button that shows up in each comment. Suggestions can also be ignored freely; the review does not block merges.

The tool and the github integration are both still in the early phases so there are probably several bugs to work out here. If a suggestion looks wonky, @-mention me and I'll take a look at it.
jackfirth added a commit to jackfirth/typed-racket that referenced this pull request Jun 26, 2022
Analyze pull requests with Resyntax

@samth expressed interest in setting up [Resyntax](https://docs.racket-lang.org/resyntax/) in the Typed Racket repository. This CL adds a github workflow which runs Resyntax on any changed files in a pull request. Resyntax will suggest changes in the form of a github review, [like this](jackfirth/racket-package-resyntax-action#9 (review)). To apply the changes, the pull request author simply need click the "Commit suggestion" button that shows up in each comment. Suggestions can also be ignored freely; the review does not block merges.

The tool and the github integration are both still in the early phases so there are probably several bugs to work out here. If a suggestion looks wonky, @-mention me and I'll take a look at it.
samth pushed a commit to racket/typed-racket that referenced this pull request Jun 26, 2022
Analyze pull requests with Resyntax

@samth expressed interest in setting up [Resyntax](https://docs.racket-lang.org/resyntax/) in the Typed Racket repository. This CL adds a github workflow which runs Resyntax on any changed files in a pull request. Resyntax will suggest changes in the form of a github review, [like this](jackfirth/racket-package-resyntax-action#9 (review)). To apply the changes, the pull request author simply need click the "Commit suggestion" button that shows up in each comment. Suggestions can also be ignored freely; the review does not block merges.

The tool and the github integration are both still in the early phases so there are probably several bugs to work out here. If a suggestion looks wonky, @-mention me and I'll take a look at it.
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

Successfully merging this pull request may close these issues.

3 participants