Git Product home page Git Product logo

appmap-ruby's People

Contributors

apotterri avatar brikelly avatar daniel-warner-x avatar dependabot[bot] avatar dividedmind avatar dustinbyrne avatar hleb-rubanau avatar kgilpin avatar lachrist avatar ptrdvrk avatar semantic-release-bot avatar symwell avatar torchello avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

appmap-ruby's Issues

"kind" is renamed to "type" in the class map

By using "type", we can introduce "subtype" which captures the language-specific name of an object.

The set of "types" will be limited to:

  • package
  • class
  • function

Whereas "subtype" can include language-specific concepts such as "module", "struct", "procedure", "method", etc.

(Bug?) Node modules data present

Hey there,

My name is Maciej Mensfeld and I run security & quality assessment for Ruby libraries using WhiteSource Diffend.io.

While reviewing the changes for this lib, I noticed, that the node modules directory is being included.

Is this needed? Usually, it's added by mistake and causes:

a) confusion
b) problems when tracking changes
c) extensive library size

ref: https://rubygems.org/gems/appmap - see the last release. 10x bigger than all the previous.
ref https://my.diffend.io/gems/appmap/0.62.0/0.62.1#d2h-432957

If the presence of vendor data is valid I would love the reasoning. Thanks!

Implement `files` command

Description

Lists relevant project and configuration-related files. This will be consumed by the IDE to watch for changes and poll the project status

Output

JSON, stdout:

{
  "configuration": ["Gemfile"],
  "test_directories": ["spec", “test”],
  "integration_test_directories": ["spec/request", "spec/system"],
  "appmap_directory": "tmp/appmap",
}

Ruby 3.0 support

Hi, is there any news on when Ruby 3.0 might be supported?

Currently when I try it, my tests fail very early (at what I think is the first method call during pre-test setup) with this error:

  ArgumentError:
    wrong number of arguments (given 1, expected 0; required keyword: category)

Googling that found me this similar-sounding issue in what I think is another one of your projects? No idea if there's any connection or not though 🙂

Tests in ShareTribe generate bad appmaps

appmap-ruby version: 0.35.1

Similar issue to ruby-rrule, appmap-ruby is generating appmaps that have return events without a corresponding call event.

Path: PeopleController_show_shows_specific_meta_title_and_description.appmap.json
ID: 219575
Issue: Missing Return event

Path: PeopleController_show_works.appmap.json
ID: 217060
Issue: Missing Return event

Ruby: implement `validate` command

Warning if appmap.yml is missing
Error if appmap.yml is not valid YAML
Error if appmap gem is not in the Gemfile
Warning if appmap gem is not the first gem in the Gemfile
Warning if appmap gem is in the production group
Warning if middleware exists and doesn’t contain remote recording

Ruby: Implement `status` command

Description

Provides project and configuration-related telemetry properties as well as information related to the execution of the application.

Output

JSON, stdout:

{
  "start_command": {
    "workingDirectory": ".",
    "command": "APPMAP=true rails s -p {{port}}",
    "baseURL": "/",
  },
  "test_commands": [
    {
      "directory": "spec",
      "command": "APPMAP=true rspec {{files}}",
    },
    {
      "directory": "test",
      "command": "APPMAP=true rails test {{files}}",
    },
  },
  "properties": {
    "config": {
      "app": "my_git_project",
      "valid": true,
      "present": true,
    },
    "project": {
      "agentVersionGlobal": "0.42.0",
      "agentVersionProject": "0.40.0",
      "language": "ruby",
      "remoteRecordingCapable": true,
      "integrationTests": true,
    }
  }
}

All classes are pruned from the diagram when uploading from the Rails sample app

With prune and reparent enabled, the class diagram is completely pruned when uploading the Rails sample app:

$ env APPLAND_URL=http://localhost:32770 BUNDLE_GEMFILE=~/source/appland/appmap-ruby/Gemfile bundle exec /Users/kgilpin/source/appland/appmap-ruby/exe/upload appmap.json
Full classMap contains 68 classes
Pruned classMap contains 0 classes

bug: Auto-generated appmap.yml is reported as invalid in non-rails ruby apps

Valid appmap.yml files are reported as invalid in projects that are not rails apps (i.e. in rails gems).

Example: https://github.com/refinery/refinerycms

Generated appmap.yml:

---
name: refinerycms
packages:
- path: lib

appmap gem info:

gem info appmap

*** LOCAL GEMS ***

appmap (0.61.1)
    Author: Kevin Gilpin
    Homepage: https://github.com/applandinc/appmap-ruby
    License: MIT
    Installed at: /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0

    Record the operation of a Ruby program, using the AppLand 'AppMap'
    format.
‣ bundle exec appmap-agent-status
{
  "test_commands": [

  ],
  "properties": {
    "config": {
      "app": "refinerycms",
      "present": true,
      "valid": false
    },
    "project": {
      "agentVersion": "0.61.1",
      "language": "ruby",
      "remoteRecordingCapable": false,
      "integrationTests": false
    }
  }
}

Loom: https://www.loom.com/share/1e69604e586b4e00a21342579b4bd503

Bug: appmap breaks tests of "ahoy" rails app

When running minitest tests with APPMAP=true, the tests break.

Gemfile:

source "https://rubygems.org"

gem 'appmap', :groups => [:development, :test]

gemspec

gem "rails", "~> 6.1.0"
gem "rake"
gem "minitest"
gem "combustion"
gem "sqlite3"
gem "pg"
# gem "mysql2"
# TODO use rubygems when > 7.2.0 is released
gem "mongoid", github: "mongodb/mongoid"
gem "browser", "~> 2.0"
gem "user_agent_parser"

appmap.yml:

---
name: ahoy
packages:
- path: app/controllers
- path: lib

Error log:

# ptrdvrk • ~/work/github/ruby/5mtv/ahoy • master*
‣ APPMAP=true bundle exec rake test
Run options: --seed 2769

# Running:

.......................Traceback (most recent call last):
        20: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:68:in `block in autorun'
        19: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:141:in `run'
        18: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:164:in `__run'
        17: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:164:in `map'
        16: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:164:in `block in __run'
        15: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:326:in `run'
        14: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:354:in `with_info_handler'
        13: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:367:in `on_signal'
        12: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:327:in `block in run'
        11: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:327:in `each'
        10: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:328:in `block (2 levels) in run'
         9: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:341:in `run_one_method'
         8: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/minitest-5.14.4/lib/minitest.rb:1029:in `run_one_method'
         7: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/appmap-0.58.0/lib/appmap/minitest.rb:148:in `run'
         6: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/appmap-0.58.0/lib/appmap/minitest.rb:81:in `end_test'
         5: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/appmap-0.58.0/lib/appmap/minitest.rb:48:in `finish'
         4: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/appmap-0.58.0/lib/appmap/minitest.rb:122:in `save'
         3: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/2.7.0/json/common.rb:224:in `generate'
         2: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/appmap-0.58.0/lib/appmap/hook/method.rb:77:in `block in activate'
         1: from /Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/appmap-0.58.0/lib/appmap/hook/method.rb:62:in `block (2 levels) in activate'
/Users/ptrdvrk/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/appmap-0.58.0/lib/appmap/hook/method.rb:62:in `generate': source sequence is illegal/malformed utf-8 (JSON::GeneratorError)
rake aborted!
Command failed with status (1)
/Users/ptrdvrk/.rbenv/versions/2.7.2/bin/bundle:23:in `load'
/Users/ptrdvrk/.rbenv/versions/2.7.2/bin/bundle:23:in `<main>'
Tasks: TOP => test
(See full trace by running task with --trace)
✖ 1

Hook Redis

Here's a representative table of Redis methods which can be hooked automatically:

├───────────────────────────────────────────────────────────┼─────────────────────────────────┼────────────────────────────────┤
│                                                           │ redis/Redis#expire              │                                │
│                                                           │ redis/Redis#get                 │                                │
│                                                           │ redis/Redis#llen                │                                │
│                                                           │ redis/Redis#lpop                │                                │
│                                                           │ redis/Redis#lpush               │                                │
│ app/integrations/FileCacheMaintainer.assign_blocklist_ids │ redis/Redis#sadd                │                                │
│ app/integrations/FileCacheMaintainer.blocklist            │ redis/Redis#smembers            │                                │
│ app/integrations/FileCacheMaintainer.blocklist            │ redis/Redis#type                │                                │
│ app/integrations/FileCacheMaintainer.blocklist_include?   │ redis/Redis#sismember           │                                │
│ app/integrations/FileCacheMaintainer.files                │ redis/Redis#hgetall             │                                │
│ app/integrations/FileCacheMaintainer.files                │ redis/Redis#type                │                                │
│ app/integrations/FileCacheMaintainer.redis                │ redis/Redis.current             │                                │
│ app/integrations/FileCacheMaintainer.remove_file          │ redis/Redis#hdel                │                                │
│ app/integrations/FileCacheMaintainer.reset_blocklist_ids  │ redis/Redis#expire              │                                │
│ app/integrations/FileCacheMaintainer.reset_file_info      │ redis/Redis#expire              │                                │
│ app/integrations/FileCacheMaintainer.update_file_info     │ redis/Redis#hset                │                                │
│ app/models/Counts.assign_for                              │ redis/Redis#hset                │                                │
│ app/models/Counts.retrieve_for                            │ redis/Redis#hget                │                                │
│ app/models/Counts.retrieve_for                            │ redis/Redis::Connection.drivers │                                │
│ app/models/Counts.week_creation_chart                     │ redis/Redis#hget                │                                │
│ app/workers/EmailUpdatedTermsWorker#perform               │ redis/Redis#llen                │                                │
│ app/workers/EmailUpdatedTermsWorker#perform               │ redis/Redis#lpop                │                                │
│ app/workers/EmailUpdatedTermsWorker#perform               │ redis/Redis#rpush               │                                │
│ app/workers/EmailUpdatedTermsWorker#redis                 │ redis/Redis.current             │                                │
│ app/workers/ScheduledWorker.redis                         │ redis/Redis#expire              │                                │
│ app/workers/ScheduledWorker.redis                         │ redis/Redis#hget                │                                │
│ app/workers/ScheduledWorker.redis                         │ redis/Redis#hset                │                                │
│ app/workers/ScheduledWorker.redis                         │ redis/Redis::Connection.drivers │                                │
│ sidekiq/Sidekiq.redis                                     │ redis/Redis#llen                │                                │
│ sidekiq/Sidekiq.redis                                     │ redis/Redis#lrange              │                                │
│ sidekiq/Sidekiq.redis                                     │ redis/Redis::Connection.drivers │                                │
│ sidekiq/Sidekiq::Testing.inline!                          │ redis/Redis#get                 │                                │
│ vcr/VCR.use_cassette                                      │ redis/Redis#get                 │                                │
└───────────────────────────────────────────────────────────┴─────────────────────────────────┴────────────────────────────────┘

"module" is renamed to "package" in the class map

"package" better captures the file-path organization of Classes and Modules, and reserves the word Modules for the specific "module" subtype of the "class" type, as it's used in Ruby.

In JavaScript, the term "module" has the same semantics as what we are using "package" for now. So in the class map, a JavaScript "module" will have type=package and subtype=module. In Ruby, the files in a directory will be organized by type=package and subtype=directory.

A Module will be type=class, subtype=module.

There's no one way that will work without modification for all languages. We just need to pick something reasonable and allow for language-specific terminology as needed.

Seg Fault When Running Tests on Redmine

Segfault occurs when running Appmap tests on Redmine.
[BUG] Segmentation fault at 0x0000000000000000

Appears to happen on multiple tests such as:

  • /home/travis/build/land-of-apps/redmine/test/functional/boards_controller_test.rb:120
  • /home/travis/build/land-of-apps/redmine/test/integration/api_test/projects_test.rb:37

Redmine logs

Ruby: adding appmap to Gemfile currupts gemfile

Original:

source 'https://rubygems.org'

ruby '>=2.5.0'

# Ensure github repositories are fetched using HTTPS
git_source(:github) do |repo_name|
  "https://github.com/#{repo_name}.git"
end

# Load vendored dotenv gem and .env file
require File.join(File.dirname(__FILE__), 'lib/gemfile_helper.rb')
GemfileHelper.load_dotenv do |dotenv_dir|
  path dotenv_dir do
    gem 'dotenv'
    gem 'dotenv-rails'
  end
end

After init

source 'https://rubygems.org'

ruby '>=2.5.0'

# Ensure github repositories are fetched using HTTPS
git_source(:github) do |repo_name|
  "https://github.com/#{repo_name}.git"
end

# Load vendored dotenv gem and .env file
require File.join(File.dirname(__FILE__), 'lib/gemfile_helper.rb')
GemfileHelper.load_dotenv do |dotenv_dir|
  path dotenv_dir do

gem 'appmap', :groups => [:development, :test]
    gem 'dotenv'
    gem 'dotenv-rails'
  end
end

bundle fails with

Fetching gem metadata from https://rubygems.org/........
Fetching gem metadata from https://rubygems.org/.
Could not find gem 'appmap' in source at `vendor/gems/dotenv-2.0.1`.
The source does not contain any versions of 'appmap'

Ruby: init makes a backup copy of the original Gemfile

I have been creating copies of the Gemfile manually to recover from potential bugs quickly. It would be good if the init function created a pre-appmap backup of the Gemfile instead.

Also, creating backups of files modified by setup scripts is IMO considered a good etiquette.

Random classes included in a map

Some classes were included into my Rails map without being explicitly required. My config was listing several packages from app folder only. I had to exclude these classes manually to reduce the "noise" in the map:

exclude:
- ActiveSupport::Callbacks::CallbackSequence
- ActionController::Instrumentation
- JSON::Ext::Generator

ArgumentError proxying kwrest arguments under certain conditions

In Ruby 2.7, the following call sequence will produce an ArgumentError:

class Kwargs
  class << self
    def no_kwargs(args)
      args
    end

    def has_kwrest_calls_no_kwargs(args, **kwargs)
      no_kwargs(**kwargs)
    end
  end
end
     Failure/Error:
       def no_kwargs(args)
         args
       end
     
     ArgumentError:
       wrong number of arguments (given 0, expected 1)
     # spec/fixtures/hook/kwargs.rb:3:in `no_kwargs'
     # ./lib/appmap/hook/method.rb:77:in `block (2 levels) in activate'
     # ./lib/appmap/hook/method.rb:100:in `block in activate'
     # spec/fixtures/hook/kwargs.rb:20:in `has_kwrest_calls_no_kwargs'

When consolidating the hierarchy, data is being mis-filed

Here' an example in which method names are duplicated in a class:

Screen Shot 2019-03-15 at 4 47 34 PM

The inspector algorithm has methods to coalesce and compact the parse tree so that, for example, all the methods of a class show up in the same JSON object even if they are declared across multiple files. These algorithms are getting it wrong sometimes, though.

Ruby: Implement `init` command

Description

Creates a base appmap.yml configuration for the current project. The name property is derived from a git remote, and the package paths from the current project directory.

Output

.appmap.yml:

name: my_git_project

packages:
  - path: app/models
  - path: app/controllers

bundle install failed with error ( I put gem in .gemfile at the top as recommended)

current directory: /home/server/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/appmap-0.64.0/ext/appmap
/home/server/.rbenv/versions/2.4.0/bin/ruby -r ./siteconf20210825-23872-14ulfow.rb extconf.rb
creating Makefile

current directory: /home/server/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/appmap-0.64.0/ext/appmap
make "DESTDIR=" clean

current directory: /home/server/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/appmap-0.64.0/ext/appmap
make "DESTDIR="
compiling appmap.c
In file included from /home/server/.rbenv/versions/2.4.0/include/ruby-2.4.0/ruby.h:33,
from appmap.c:1:
/home/server/.rbenv/versions/2.4.0/include/ruby-2.4.0/ruby/ruby.h:627:1: error: ‘const’ attribute on function returning ‘void’ [-Werror=attributes]
627 | CONSTFUNC(void rb_secure_update(VALUE));
| ^~~~~~~~~
In file included from /home/server/.rbenv/versions/2.4.0/include/ruby-2.4.0/ruby/ruby.h:2001,
from /home/server/.rbenv/versions/2.4.0/include/ruby-2.4.0/ruby.h:33,
from appmap.c:1:
/home/server/.rbenv/versions/2.4.0/include/ruby-2.4.0/ruby/intern.h:257:1: error: ‘const’ attribute on function returning ‘void’ [-Werror=attributes]
257 | CONSTFUNC(void rb_error_untrusted(VALUE));
| ^~~~~~~~~
/home/server/.rbenv/versions/2.4.0/include/ruby-2.4.0/ruby/intern.h:259:1: error: ‘const’ attribute on function returning ‘void’ [-Werror=attributes]
259 | CONSTFUNC(void rb_check_trusted(VALUE));
| ^~~~~~~~~
cc1: all warnings being treated as errors
make: *** [Makefile:242: appmap.o] Ошибка 1

make failed, exit code 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.