0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

R CMD check でMalformed Description field: should contain one or more complete sentences.となる理由の調査

Last updated at Posted at 2015-09-02

普段全くRを使わないものがこの記事を書いています。

概要

R CMD check をしたときに、Descriptionをきちんと書いていると思っているが、タイトルのような出力となる。
この原因を調査した。

結論

以下のようなソースコードで判定されていると考えている。
Malformed...の出力をとめるには、
ピリオドで終わるなど、次の条件にマッチするようにすればよい。

## some people put punctuation inside quotes, some outside.
if(strict && !is.na(val <- db["Description"])
   && !grepl("[.!?]['\")]?$", trimws(val)))
    out$bad_Description <- TRUE

Rのバージョン

使用したRのバージョン

ソフトウェア バージョン
R R version 3.2.2 Patched (2015-08-27 r69199) -- "Fire Safety"

R-latest.tar.gzを持ってきて自分でコンパイルしたもの。

調査

Google で調べてみた

上のスライドの19枚目で書いているが、よくわからなかった。
下の議論は長かったので、とりあえず、ソースコードのgrepをしながら読んでいたのだけど、よくわからなかった。

ソースコードのgrepの結果

コンパイルしたあとのディレクトリで、以下のようなコマンドを実行した

grep -r "Malformed Description field: should contain one or more complete sentences" *

それっぽい行が2つヒットしていた

src/library/tools/R/QC.R:        writeLines(gettext("Malformed Description field: should contain one or more complete sentences."))
src/library/tools/all.R:        writeLines(gettext("Malformed Description field: should contain one or more complete sentences."))

どちらも同じような内容で、問題の出力は以下のところで行っていると考えた。


if(identical(x$bad_Description, TRUE))
    writeLines(gettext("Malformed Description field: should contain one or more complete sentences."))

bad_Descriptionについては、この文書の冒頭にあげたように以下のようなコードとなっている。
きちんと深くはおっていないが、このファイルの中ではここだけであったので。

## some people put punctuation inside quotes, some outside.
if(strict && !is.na(val <- db["Description"])
   && !grepl("[.!?]['\")]?$", trimws(val)))
    out$bad_Description <- TRUE

正規表現の感じからすると、最後の文字が何かが問題ようだとおもったので、Rを起動して以下のような感じで動かした。


> val="hello"
> grepl("[.!?]['\")]?$", trimws(val))
[1] FALSE
> val="hello."
> grepl("[.!?]['\")]?$", trimws(val))
[1] TRUE

最初はhelloだけでFALSEになっていて、次にピリオドをつけたらTRUEになった。
上に上げた条件式としてはおそらくピリオドが最後であれば Malformed と言われることはないだろうというのが結論。

参考

上にあげたスライドの19枚目をみると

文章 結果
My awesome R package NG
This package is awesome NG
Blah blah blah. OK

となっている。
おそらく、最後のだけ通っているのは、最後の文字がピリオドだからではないか。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?