Fix "undefined method `<'" error message#774
Merged
drwl merged 2 commits intoctran:developfrom Apr 5, 2020
erikkessler1:ekessler1/fix-non-class
Merged
Fix "undefined method `<'" error message#774drwl merged 2 commits intoctran:developfrom erikkessler1:ekessler1/fix-non-class
drwl merged 2 commits intoctran:developfrom
erikkessler1:ekessler1/fix-non-class
Conversation
This checks that the object we are trying to annotate is a Class to ensure it has the interface we expect.
drwl
approved these changes
Apr 5, 2020
Collaborator
drwl
left a comment
There was a problem hiding this comment.
Thanks for contributing! Looks good to me.
vfonic
pushed a commit
to vfonic/annotate_models
that referenced
this pull request
May 8, 2020
## Problem I have some files in the "models" directory that are not true a `Class`. For example, a [`dry-types`](https://dry-rb.org/gems/dry-types/1.2/sum/) sum type: ```ruby # app/models/foo.rb Foo = Types::String | Types::Integer ``` This results in the following line when I annotate. ``` Unable to annotate app/models/foo.rb: undefined method `<' for #<Dry::Struct::Sum:0x00007ff2dd262988> ``` Not a blocking issue but somewhat annoying nonetheless. ## Solution When annotating a file, check that the file's object is a `Class` to ensure it has the interface we expect.
ctran
pushed a commit
that referenced
this pull request
Jun 14, 2021
This commit partially reverts #801, which by declaring conditional return has turned `get_loaded_model_by_path` to a less safe method that can return nil when its the condition is not met. Apparently the very same condition has been brought to `annotate_model_file` by #774, which seems to cover the "bug" insisted in #801 as well. On the other hand #801 has brought an inconvenient behaviour as well: whenever a non-activerecord model file is found, `get_loaded_model_by_path` returns nil, which leads to raising `BadModelFileError` and ends up printing a bunch of "Unable to annotate ..." messages. Now it seems tests added by #801 are running right and I do not find a problem restoring the previous behaviour and turn it nil-safe again.
ocarta-l
pushed a commit
to ocarta-l/annotate_models
that referenced
this pull request
Jun 18, 2021
This commit partially reverts ctran#801, which by declaring conditional return has turned `get_loaded_model_by_path` to a less safe method that can return nil when its the condition is not met. Apparently the very same condition has been brought to `annotate_model_file` by ctran#774, which seems to cover the "bug" insisted in ctran#801 as well. On the other hand ctran#801 has brought an inconvenient behaviour as well: whenever a non-activerecord model file is found, `get_loaded_model_by_path` returns nil, which leads to raising `BadModelFileError` and ends up printing a bunch of "Unable to annotate ..." messages. Now it seems tests added by ctran#801 are running right and I do not find a problem restoring the previous behaviour and turn it nil-safe again.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
I have some files in the "models" directory that are not true a
Class. For example, adry-typessum type:This results in the following line when I annotate.
Not a blocking issue but somewhat annoying nonetheless.
Solution
When annotating a file, check that the file's object is a
Classto ensure it has the interface we expect.