Skip to content
This repository was archived by the owner on Jun 20, 2025. It is now read-only.

Add Rollbar-to-BasecampСhat events posting#15

Open
fatbelfegor wants to merge 115 commits into
mkdev-me:masterfrom
fatbelfegor:master
Open

Add Rollbar-to-BasecampСhat events posting#15
fatbelfegor wants to merge 115 commits into
mkdev-me:masterfrom
fatbelfegor:master

Conversation

@fatbelfegor
Copy link
Copy Markdown
Contributor

@fatbelfegor fatbelfegor commented Mar 26, 2017

README.md

  • Add Rollbar Instructions
  • Add Bugsnag Instructions
  • Add Gitlab Instructions
  • Add Giphy Instructions
  • Fix Amazon SNS instructions

app/helpers/application_helper.rb - common methods for all controllers. Parse requests, handle exceptions and message sending.

messages_controller.rb - store parsed data and preparing the message.

Comment thread config/routes.rb Outdated
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html

namespace :commands, defaults: {format: :json} do
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Space inside { missing.
Space inside } missing.

Comment thread config/initializers/aws_sdk.rb Outdated
@@ -0,0 +1,12 @@
# aws_secret_file: path to *.yml file with AWS_ACCESS_KEY_ID and AWS_SECRET_KEY_ID if exist
aws_secret_file = Rails.configuration.service['aws_secret_file']
aws_region = Rails.configuration.service['aws_region']
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Useless assignment to variable - aws_region.

rescue NoMethodError => e # del. exception handlidg to see errors in console
return "<strong>Bugsnag parsing error:</strong> #{e}"
end
end No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Final newline missing.


private

def build_message_text(command_parsed)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unused method argument - command_parsed. If it's necessary, use _ or _command_parsed as an argument name to indicate that it won't be used. You can also write as build_message_text(*) if you want the method to accept any arguments but don't care about them.

@@ -0,0 +1,36 @@
class Commands::CommandsController < ApplicationController
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing top-level class documentation comment.
Missing frozen string literal comment.
Use nested module/class definitions instead of compact style.


if amazon_sns_request['Type'].to_s.casecmp('SubscriptionConfirmation') >= 0
client.confirm_subscription(
topic_arn: snstopic_arn,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Indent the first parameter one step more than the start of the previous line.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Коммент актуален

class Api::Sns::MessagesController < ApplicationController
skip_before_action :verify_authenticity_token

def create
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Assignment Branch Condition size for create is too high. [24.6/15]
Method has too many lines. [13/10]

@@ -0,0 +1,8 @@
class Api::Giphy::MessagesController < ApplicationController
skip_before_action :verify_authenticity_token
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

DRY


if amazon_sns_request['Type'].to_s.casecmp('SubscriptionConfirmation') >= 0
client.confirm_subscription(
topic_arn: snstopic_arn,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Коммент актуален

Comment thread config/service.yml Outdated
production:
<<: *default No newline at end of file
basecampbot_url: <%= ENV["BASECAMPBOT_URL"] %>
giphy_api_key: <%= ENV["GIPHY_API_KEY"] %>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

отступы

@@ -1,2 +1,14 @@
module ApplicationHelper
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

let;s create new class, app/models/chatbot.rb:

class Chatbot

  class << self
    def parse_webhook
    # ...
    end
    
    def send_message
    # ...
    end
    end
end

@@ -0,0 +1,11 @@
# aws_secret_file: path to *.yml file with AWS_ACCESS_KEY_ID and AWS_SECRET_KEY_ID if exist
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing frozen string literal comment.
Line is too long. [91/80]

Comment thread app/models/chatbot.rb Outdated
@@ -0,0 +1,14 @@
class Chatbot

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Trailing whitespace detected.

Comment thread app/models/chatbot.rb
@@ -0,0 +1,14 @@
class Chatbot
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing top-level class documentation comment.
Missing frozen string literal comment.

class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
skip_before_action :verify_authenticity_token, if: :json_request?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Trailing whitespace detected.

@@ -0,0 +1,33 @@
class Api::Sns::MessagesController < ApplicationController

def create
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Assignment Branch Condition size for create is too high. [25.57/15]
Method has too many lines. [13/10]

@@ -0,0 +1,35 @@
class Api::Gitlab::MessagesController < ApplicationController

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Extra empty line detected at class body beginning.


def create
image = Giphy.random(command_params[:command]).image_original_url.to_s
Chatbot.send_message(command_params[:callback_url], "<img src='#{image}' />")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Line is too long. [81/80]

@@ -0,0 +1,7 @@
class Api::Giphy::MessagesController < ApplicationController

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Extra empty line detected at class body beginning.

@@ -0,0 +1,7 @@
class Api::Giphy::MessagesController < ApplicationController
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing top-level class documentation comment.
Missing frozen string literal comment.
Use nested module/class definitions instead of compact style.

@@ -0,0 +1,35 @@
class Api::Bugsnag::MessagesController < ApplicationController

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Extra empty line detected at class body beginning.

Comment thread app/models/chatbot.rb Outdated
@@ -0,0 +1,14 @@
class Chatbot

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Extra empty line detected at class body beginning.

@@ -0,0 +1,35 @@
class Api::Bugsnag::MessagesController < ApplicationController
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing top-level class documentation comment.
Missing frozen string literal comment.
Use nested module/class definitions instead of compact style.

@@ -0,0 +1,32 @@
class Api::Sns::MessagesController < ApplicationController
def create
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Assignment Branch Condition size for create is too high. [25.57/15]
Method has too many lines. [13/10]

class Api::Giphy::MessagesController < ApplicationController
def create
image = Giphy.random(command_params[:command]).image_original_url.to_s
Chatbot.send_message(command_params[:callback_url], "<img src='#{image}' />")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Line is too long. [81/80]

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants