Module: PlatformosCheck

Defined in:
lib/platformos_check/disabled_check.rb,
lib/platformos_check.rb,
lib/platformos_check/app.rb,
lib/platformos_check/bug.rb,
lib/platformos_check/cli.rb,
lib/platformos_check/node.rb,
lib/platformos_check/tags.rb,
lib/platformos_check/check.rb,
lib/platformos_check/checks.rb,
lib/platformos_check/config.rb,
lib/platformos_check/offense.rb,
lib/platformos_check/printer.rb,
lib/platformos_check/storage.rb,
lib/platformos_check/version.rb,
lib/platformos_check/analyzer.rb,
lib/platformos_check/app_file.rb,
lib/platformos_check/position.rb,
lib/platformos_check/releaser.rb,
lib/platformos_check/sms_file.rb,
lib/platformos_check/tags/log.rb,
lib/platformos_check/tags/try.rb,
lib/platformos_check/corrector.rb,
lib/platformos_check/form_file.rb,
lib/platformos_check/html_node.rb,
lib/platformos_check/json_file.rb,
lib/platformos_check/page_file.rb,
lib/platformos_check/tags/base.rb,
lib/platformos_check/tags/form.rb,
lib/platformos_check/yaml_file.rb,
lib/platformos_check/asset_file.rb,
lib/platformos_check/email_file.rb,
lib/platformos_check/exceptions.rb,
lib/platformos_check/html_check.rb,
lib/platformos_check/tags/cache.rb,
lib/platformos_check/tags/print.rb,
lib/platformos_check/yaml_check.rb,
lib/platformos_check/config_file.rb,
lib/platformos_check/json_helper.rb,
lib/platformos_check/layout_file.rb,
lib/platformos_check/liquid_file.rb,
lib/platformos_check/liquid_node.rb,
lib/platformos_check/schema_file.rb,
lib/platformos_check/tags/export.rb,
lib/platformos_check/tags/render.rb,
lib/platformos_check/tags/return.rb,
lib/platformos_check/graphql_file.rb,
lib/platformos_check/html_visitor.rb,
lib/platformos_check/json_helpers.rb,
lib/platformos_check/json_printer.rb,
lib/platformos_check/liquid_check.rb,
lib/platformos_check/partial_file.rb,
lib/platformos_check/tags/context.rb,
lib/platformos_check/tags/graphql.rb,
lib/platformos_check/tags/session.rb,
lib/platformos_check/tags/sign_in.rb,
lib/platformos_check/api_call_file.rb,
lib/platformos_check/regex_helpers.rb,
lib/platformos_check/tags/function.rb,
lib/platformos_check/liquid_visitor.rb,
lib/platformos_check/migration_file.rb,
lib/platformos_check/string_helpers.rb,
lib/platformos_check/checks_tracking.rb,
lib/platformos_check/disabled_checks.rb,
lib/platformos_check/language_server.rb,
lib/platformos_check/parsing_helpers.rb,
lib/platformos_check/position_helper.rb,
lib/platformos_check/tags/background.rb,
lib/platformos_check/tags/base_block.rb,
lib/platformos_check/tags/parse_json.rb,
lib/platformos_check/tags/hash_assign.rb,
lib/platformos_check/tags/redirect_to.rb,
lib/platformos_check/translation_file.rb,
lib/platformos_check/user_schema_file.rb,
lib/platformos_check/app_file_rewriter.rb,
lib/platformos_check/checks/liquid_tag.rb,
lib/platformos_check/checks/valid_yaml.rb,
lib/platformos_check/graphql_traverser.rb,
lib/platformos_check/in_memory_storage.rb,
lib/platformos_check/tags/theme_render.rb,
lib/platformos_check/checks/form_action.rb,
lib/platformos_check/checks/invalid_args.rb,
lib/platformos_check/checks/syntax_error.rb,
lib/platformos_check/file_system_storage.rb,
lib/platformos_check/checks/unused_assign.rb,
lib/platformos_check/tags/response_status.rb,
lib/platformos_check/tags/spam_protection.rb,
lib/platformos_check/checks/unknown_filter.rb,
lib/platformos_check/checks/unused_partial.rb,
lib/platformos_check/platformos_liquid/tag.rb,
lib/platformos_check/tags/base_tag_methods.rb,
lib/platformos_check/tags/response_headers.rb,
lib/platformos_check/checks/template_length.rb,
lib/platformos_check/language_server/bridge.rb,
lib/platformos_check/language_server/server.rb,
lib/platformos_check/language_server/tokens.rb,
lib/platformos_check/checks/img_lazy_loading.rb,
lib/platformos_check/checks/missing_template.rb,
lib/platformos_check/checks/undefined_object.rb,
lib/platformos_check/checks/unreachable_code.rb,
lib/platformos_check/language_server/channel.rb,
lib/platformos_check/language_server/handler.rb,
lib/platformos_check/checks/deprecated_filter.rb,
lib/platformos_check/checks/include_in_render.rb,
lib/platformos_check/checks/parse_json_format.rb,
lib/platformos_check/language_server/protocol.rb,
lib/platformos_check/platformos_liquid/filter.rb,
lib/platformos_check/platformos_liquid/object.rb,
lib/platformos_check/checks/html_parsing_error.rb,
lib/platformos_check/language_server/constants.rb,
lib/platformos_check/language_server/messenger.rb,
lib/platformos_check/checks/graphql_in_for_loop.rb,
lib/platformos_check/checks/space_inside_braces.rb,
lib/platformos_check/language_server/diagnostic.rb,
lib/platformos_check/language_server/uri_helper.rb,
lib/platformos_check/checks/img_width_and_height.rb,
lib/platformos_check/language_server/type_helper.rb,
lib/platformos_check/language_server/hover_engine.rb,
lib/platformos_check/language_server/io_messenger.rb,
lib/platformos_check/checks/missing_enable_comment.rb,
lib/platformos_check/checks/required_layout_object.rb,
lib/platformos_check/checks/translation_key_exists.rb,
lib/platformos_check/language_server/configuration.rb,
lib/platformos_check/checks/form_authenticity_token.rb,
lib/platformos_check/checks/translation_files_match.rb,
lib/platformos_check/language_server/hover_provider.rb,
lib/platformos_check/platformos_liquid/source_index.rb,
lib/platformos_check/platformos_liquid/documentation.rb,
lib/platformos_check/checks/convert_include_to_render.rb,
lib/platformos_check/platformos_liquid/source_manager.rb,
lib/platformos_check/checks/parser_blocking_javascript.rb,
lib/platformos_check/language_server/completion_engine.rb,
lib/platformos_check/language_server/completion_helper.rb,
lib/platformos_check/language_server/code_action_engine.rb,
lib/platformos_check/language_server/completion_context.rb,
lib/platformos_check/language_server/diagnostics_engine.rb,
lib/platformos_check/language_server/client_capabilities.rb,
lib/platformos_check/language_server/completion_provider.rb,
lib/platformos_check/language_server/diagnostics_manager.rb,
lib/platformos_check/platformos_liquid/deprecated_filter.rb,
lib/platformos_check/language_server/code_action_provider.rb,
lib/platformos_check/language_server/document_link_engine.rb,
lib/platformos_check/language_server/document_link_provider.rb,
lib/platformos_check/language_server/execute_command_engine.rb,
lib/platformos_check/language_server/variable_lookup_finder.rb,
lib/platformos_check/language_server/execute_command_provider.rb,
lib/platformos_check/platformos_liquid/source_index/tag_entry.rb,
lib/platformos_check/platformos_liquid/source_index/tag_state.rb,
lib/platformos_check/language_server/document_change_corrector.rb,
lib/platformos_check/language_server/variable_lookup_traverser.rb,
lib/platformos_check/platformos_liquid/source_index/base_entry.rb,
lib/platformos_check/platformos_liquid/source_index/base_state.rb,
lib/platformos_check/language_server/partial_completion_provider.rb,
lib/platformos_check/language_server/versioned_in_memory_storage.rb,
lib/platformos_check/platformos_liquid/source_index/filter_entry.rb,
lib/platformos_check/platformos_liquid/source_index/filter_state.rb,
lib/platformos_check/platformos_liquid/source_index/object_entry.rb,
lib/platformos_check/platformos_liquid/source_index/object_state.rb,
lib/platformos_check/platformos_liquid/source_index/property_entry.rb,
lib/platformos_check/platformos_liquid/source_index/parameter_entry.rb,
lib/platformos_check/language_server/variable_lookup_finder/constants.rb,
lib/platformos_check/platformos_liquid/source_index/return_type_entry.rb,
lib/platformos_check/platformos_liquid/documentation/markdown_template.rb,
lib/platformos_check/language_server/hover_providers/tag_hover_provider.rb,
lib/platformos_check/language_server/variable_lookup_finder/liquid_fixer.rb,
lib/platformos_check/language_server/hover_providers/filter_hover_provider.rb,
lib/platformos_check/language_server/variable_lookup_finder/tolerant_parser.rb,
lib/platformos_check/language_server/variable_lookup_finder/potential_lookup.rb,
lib/platformos_check/language_server/variable_lookup_finder/assignments_finder.rb,
lib/platformos_check/language_server/completion_providers/tag_completion_provider.rb,
lib/platformos_check/language_server/completion_providers/filter_completion_provider.rb,
lib/platformos_check/language_server/completion_providers/object_completion_provider.rb,
lib/platformos_check/language_server/variable_lookup_finder/assignments_finder/scope.rb,
lib/platformos_check/language_server/code_action_providers/quickfix_code_action_provider.rb,
lib/platformos_check/language_server/completion_providers/assignments_completion_provider.rb,
lib/platformos_check/language_server/document_link_providers/asset_document_link_provider.rb,
lib/platformos_check/language_server/document_link_providers/render_document_link_provider.rb,
lib/platformos_check/language_server/document_link_providers/graphql_document_link_provider.rb,
lib/platformos_check/language_server/document_link_providers/include_document_link_provider.rb,
lib/platformos_check/language_server/variable_lookup_finder/assignments_finder/node_handler.rb,
lib/platformos_check/language_server/completion_providers/render_partial_completion_provider.rb,
lib/platformos_check/language_server/document_link_providers/function_document_link_provider.rb,
lib/platformos_check/language_server/document_link_providers/localize_document_link_provider.rb,
lib/platformos_check/language_server/variable_lookup_finder/assignments_finder/scope_visitor.rb,
lib/platformos_check/language_server/completion_providers/graphql_partial_completion_provider.rb,
lib/platformos_check/language_server/completion_providers/include_partial_completion_provider.rb,
lib/platformos_check/language_server/code_action_providers/source_fix_all_code_action_provider.rb,
lib/platformos_check/language_server/completion_providers/function_partial_completion_provider.rb,
lib/platformos_check/language_server/completion_providers/object_attribute_completion_provider.rb,
lib/platformos_check/language_server/document_link_providers/background_document_link_provider.rb,
lib/platformos_check/language_server/document_link_providers/translation_document_link_provider.rb,
lib/platformos_check/language_server/completion_providers/background_partial_completion_provider.rb,
lib/platformos_check/language_server/document_link_providers/include_form_document_link_provider.rb,
lib/platformos_check/language_server/document_link_providers/theme_render_document_link_provider.rb,
lib/platformos_check/language_server/execute_command_providers/correction_execute_command_provider.rb,
lib/platformos_check/language_server/execute_command_providers/run_checks_execute_command_provider.rb

Overview

Here we define the Language Server Protocol Constants we’re using. For complete docs, see the following: microsoft.github.io/language-server-protocol/specifications/specification-current

Defined Under Namespace

Modules: ChecksTracking, JsonHelpers, LanguageServer, ParsingHelpers, PlatformosLiquid, PositionHelper, RegexHelpers, StringHelpers, Tags Classes: Analyzer, ApiCallFile, App, AppFile, AppFileRewriter, AssetFile, Check, Checks, Cli, Config, ConfigFile, ConvertIncludeToRender, Corrector, DeprecatedFilter, DisabledCheck, DisabledChecks, EmailFile, FileSystemStorage, FormAction, FormAuthenticityToken, FormFile, GraphqlFile, GraphqlInForLoop, GraphqlTraverser, HtmlCheck, HtmlNode, HtmlParsingError, HtmlVisitor, ImgLazyLoading, ImgWidthAndHeight, InMemoryStorage, IncludeInRender, InvalidArgs, JsonFile, JsonHelper, JsonPrinter, LayoutFile, LiquidCheck, LiquidFile, LiquidNode, LiquidTag, LiquidVisitor, MigrationFile, MissingEnableComment, MissingTemplate, Node, Offense, PageFile, ParseJsonFormat, ParserBlockingJavaScript, PartialFile, PlatformosCheckError, Position, Printer, Releaser, RequiredLayoutObject, SchemaFile, SmsFile, SpaceInsideBraces, Storage, StrictPosition, SyntaxError, TemplateLength, Token, Tokens, TranslationFile, TranslationFilesMatch, TranslationKeyExists, UndefinedObject, UnknownFilter, UnreachableCode, UnusedAssign, UnusedPartial, UserSchemaFile, ValidYaml, VersionedInMemoryStorage, YamlCheck, YamlFile

Constant Summary collapse

BUG_POSTAMBLE =
<<~EOS
  PlatformOS Check Version: #{VERSION}
  Ruby Version: #{RUBY_VERSION}
  Platform: #{RUBY_PLATFORM}
  Muffin mode: activated

  ------------------------
  Whoops! It looks like you found a bug in PlatformOS Check.
  Please report it at https://github.com/Platform-OS/platformos-lsp/issues, and include the message above.
  Or cross your fingers real hard, and try again.
EOS
VERSION =
"0.4.14"
TIMEOUT_EXCEPTIONS =
[
  Net::ReadTimeout,
  Net::OpenTimeout,
  Net::WriteTimeout,
  Errno::ETIMEDOUT,
  Timeout::Error
]
CONNECTION_EXCEPTIONS =
[
  IOError,
  EOFError,
  SocketError,
  Errno::EINVAL,
  Errno::ECONNRESET,
  Errno::ECONNABORTED,
  Errno::EPIPE,
  Errno::ECONNREFUSED,
  Errno::EAGAIN,
  Errno::EHOSTUNREACH,
  Errno::ENETUNREACH,
  Errno::EADDRNOTAVAIL
]
NET_HTTP_EXCEPTIONS =
[
  Net::HTTPBadResponse,
  Net::HTTPHeaderSyntaxError,
  Net::ProtocolError,
  *TIMEOUT_EXCEPTIONS,
  *CONNECTION_EXCEPTIONS
]
TAG_START =
Liquid::TagStart
TAG_END =
Liquid::TagEnd
VARIABLE_START =
Liquid::VariableStart
VARIABLE_END =
Liquid::VariableEnd
SPLITTER =
%r{
  (?=(?:#{TAG_START}|#{VARIABLE_START}))| # positive lookahead on tag/variable start
  (?<=(?:#{TAG_END}|#{VARIABLE_END}))     # positive lookbehind on tag/variable end
}xom

Class Method Summary collapse

Class Method Details

.bug(message) ⇒ Object



20
21
22
# File 'lib/platformos_check/bug.rb', line 20

def self.bug(message)
  raise PlatformosCheckError, message + BUG_POSTAMBLE
end

.debug?Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/platformos_check.rb', line 93

def self.debug?
  ENV["PLATFORMOS_CHECK_DEBUG"] == "true"
end

.debug_log_fileObject



97
98
99
# File 'lib/platformos_check.rb', line 97

def self.debug_log_file
  ENV.fetch("PLATFORMOS_CHECK_DEBUG_LOG_FILE", nil)
end

.log(message) ⇒ Object



111
112
113
114
# File 'lib/platformos_check.rb', line 111

def self.log(message)
  bridge = LanguageServer::Bridge.new(LanguageServer::IOMessenger.new)
  bridge.log("###############\n #{message}\n##################")
end

.with_liquid_c_disabledObject



101
102
103
104
105
106
107
108
109
# File 'lib/platformos_check.rb', line 101

def self.with_liquid_c_disabled
  if defined?(Liquid::C)
    was_enabled = Liquid::C.enabled
    Liquid::C.enabled = false if was_enabled
  end
  yield
ensure
  Liquid::C.enabled = true if defined?(Liquid::C) && was_enabled
end